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 aReloadRequest, 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( aReloadRequest )
101  draw3DFrame->ReloadRequest();
102 
103  draw3DFrame->Redraw();
104  }
105 }
106 
107 
109 {
110  // This is a lazy loading function, it loads the project specific table when
111  // that table is asked for, not before.
112 
114 
115  // its gotta be NULL or a FP_LIB_TABLE, or a bug.
116  wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
117 
118  if( !tbl )
119  {
120  // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
121  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
122  // stack this way, all using the same global fallback table.
123  tbl = new FP_LIB_TABLE( &GFootprintTable );
124 
125  SetElem( ELEM_FPTBL, tbl );
126 
127  wxString projectFpLibTableFileName = FootprintLibTblName();
128 
129  try
130  {
131  tbl->Load( projectFpLibTableFileName );
132  }
133  catch( const IO_ERROR& ioe )
134  {
135  DisplayErrorMessage( nullptr, _( "Error loading project footprint libraries" ),
136  ioe.What() );
137  }
138  }
139 
140  return tbl;
141 }
142 
143 
145 {
146  if( m_pcb != aBoard )
147  {
148  delete m_pcb;
149  m_pcb = aBoard;
150 
151  wxCommandEvent e( BOARD_CHANGED );
152  ProcessEventLocally( e );
153  }
154 }
155 
156 
158 {
159  if( aFootprint )
160  {
161  GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
162 
163  aFootprint->SetFlags( IS_NEW );
164  aFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
165 
166  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
167  // built from a board)
168  if( aFootprint->IsFlipped() )
169  aFootprint->Flip( aFootprint->GetPosition(), m_settings->m_FlipLeftRight );
170 
171  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
172  // it might be stored in another orientation if the lib is an archive built from a board)
173  aFootprint->SetOrientation( 0 );
174  }
175 }
176 
177 
179 {
180  return GetBoard()->GetItem( aId );
181 }
182 
183 
185 {
186  static KIID lastBrightenedItemID( niluuid );
187 
188  BOARD_ITEM* lastItem = nullptr;
189 
192 #if BOOST_VERSION >= 106700
193  try
194  {
195  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
196  }
197  catch( const boost::uuids::entropy_error& )
198  {
199  wxLogError( "A Boost UUID entropy exception was thrown in %s:%s.", __FILE__, __FUNCTION__ );
200  }
201 #else
202  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
203 #endif
204 
205  if( lastItem && lastItem != aItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
206  {
207  lastItem->ClearBrightened();
208 
209  if( lastItem->Type() == PCB_FOOTPRINT_T )
210  {
211  static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
212  [&]( BOARD_ITEM* child )
213  {
214  child->ClearBrightened();
215  } );
216  }
217  else if( lastItem->Type() == PCB_GROUP_T )
218  {
219  static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
220  [&]( BOARD_ITEM* child )
221  {
222  child->ClearBrightened();
223  } );
224  }
225 
226  GetCanvas()->GetView()->Update( lastItem );
227  lastBrightenedItemID = niluuid;
228  GetCanvas()->Refresh();
229  }
230 
231  if( aItem && aItem != DELETED_BOARD_ITEM::GetInstance() )
232  {
233  aItem->SetBrightened();
234 
235  if( aItem->Type() == PCB_FOOTPRINT_T )
236  {
237  static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
238  [&]( BOARD_ITEM* child )
239  {
240  child->SetBrightened();
241  });
242  }
243  else if( aItem->Type() == PCB_GROUP_T )
244  {
245  static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
246  [&]( BOARD_ITEM* child )
247  {
248  child->SetBrightened();
249  });
250  }
251 
252  GetCanvas()->GetView()->Update( aItem );
253  lastBrightenedItemID = aItem->m_Uuid;
254  FocusOnLocation( aItem->GetFocusPosition() );
255  GetCanvas()->Refresh();
256  }
257 }
258 
259 
260 void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
261 {
262  m_pcb->SetPageSettings( aPageSettings );
263 
264  if( GetScreen() )
265  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
266 }
267 
268 
270 {
271  return m_pcb->GetPageSettings();
272 }
273 
274 
275 const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
276 {
277  // this function is only needed because EDA_DRAW_FRAME is not compiled
278  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
279  // into an application specific source file.
280  return m_pcb->GetPageSettings().GetSizeIU();
281 }
282 
283 
284 const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
285 {
287 }
288 
289 
290 void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
291 {
293 }
294 
295 
296 const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
297 {
299 }
300 
301 
302 const wxPoint PCB_BASE_FRAME::GetUserOrigin() const
303 {
304  auto& displ_opts = GetDisplayOptions();
305  wxPoint origin( 0, 0 );
306 
307  switch( displ_opts.m_DisplayOrigin )
308  {
310  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
311  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID: origin = GetGridOrigin(); break;
312  default: wxASSERT( false ); break;
313  }
314 
315  return origin;
316 }
317 
319 {
320  return m_originTransforms;
321 }
322 
323 
325 {
326  return m_pcb->GetTitleBlock();
327 }
328 
329 
330 void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
331 {
332  m_pcb->SetTitleBlock( aTitleBlock );
333 }
334 
335 
337 {
338  return m_pcb->GetDesignSettings();
339 }
340 
341 
343 {
344  m_drawBgColor= aColor;
345  m_auimgr.Update();
346 }
347 
348 
350 {
352 }
353 
354 
356 {
358 }
359 
360 
362 {
363  return m_pcb->GetPlotOptions();
364 }
365 
366 
368 {
369  m_pcb->SetPlotOptions( aSettings );
370 }
371 
372 
373 EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
374 {
375  EDA_RECT area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
376 
377  if( area.GetWidth() == 0 && area.GetHeight() == 0 )
378  {
379  wxSize pageSize = GetPageSizeIU();
380 
382  {
383  area.SetOrigin( 0, 0 );
384  area.SetEnd( pageSize.x, pageSize.y );
385  }
386  else
387  {
388  area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
389  area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
390  }
391  }
392 
393  return area;
394 }
395 
396 
397 // Virtual function
399 {
400 }
401 
402 
404 {
405  // call my base class
407 
408  // tooltips in toolbars
410 
411  // status bar
412  UpdateMsgPanel();
413 }
414 
415 
417 {
418  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
419 
420  if( !draw3DFrame )
421  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
422 
423  // Raising the window does not show the window on Windows if iconized. This should work
424  // on any platform.
425  if( draw3DFrame->IsIconized() )
426  draw3DFrame->Iconize( false );
427 
428  draw3DFrame->Raise();
429  draw3DFrame->Show( true );
430 
431  // Raising the window does not set the focus on Linux. This should work on any platform.
432  if( wxWindow::FindFocus() != draw3DFrame )
433  draw3DFrame->SetFocus();
434 
435  return draw3DFrame;
436 }
437 
438 
439 // Note: virtual, overridden in PCB_EDIT_FRAME;
441 {
442  PCB_LAYER_ID preslayer = GetActiveLayer();
443  auto& displ_opts = GetDisplayOptions();
444 
445  // Check if the specified layer matches the present layer
446  if( layer == preslayer )
447  return;
448 
449  // Copper layers cannot be selected unconditionally; how many of those layers are
450  // currently enabled needs to be checked.
451  if( IsCopperLayer( layer ) )
452  {
453  // If only one copper layer is enabled, the only such layer that can be selected to
454  // is the "Copper" layer (so the selection of any other copper layer is disregarded).
455  if( m_pcb->GetCopperLayerCount() < 2 )
456  {
457  if( layer != B_Cu )
458  return;
459  }
460 
461  // If more than one copper layer is enabled, the "Copper" and "Component" layers
462  // can be selected, but the total number of copper layers determines which internal
463  // layers are also capable of being selected.
464  else
465  {
466  if( layer != B_Cu && layer != F_Cu && layer >= ( m_pcb->GetCopperLayerCount() - 1 ) )
467  return;
468  }
469  }
470 
471  // Is yet more checking required? E.g. when the layer to be selected is a non-copper
472  // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
473  // ...
474 
475  SetActiveLayer( layer );
476 
477  if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
478  GetCanvas()->Refresh();
479 }
480 
481 
483 {
485  GetCanvas()->GetView() );
486 
487  // account for the globals
489  guide.SetIgnoreMTextsOnBack( ! m_pcb->IsElementVisible( LAYER_MOD_TEXT_BK ) );
490  guide.SetIgnoreMTextsOnFront( ! m_pcb->IsElementVisible( LAYER_MOD_TEXT_FR ) );
491  guide.SetIgnoreModulesOnBack( ! m_pcb->IsElementVisible( LAYER_MOD_BK ) );
492  guide.SetIgnoreModulesOnFront( ! m_pcb->IsElementVisible( LAYER_MOD_FR ) );
493  guide.SetIgnorePadsOnBack( ! m_pcb->IsElementVisible( LAYER_PAD_BK ) );
494  guide.SetIgnorePadsOnFront( ! m_pcb->IsElementVisible( LAYER_PAD_FR ) );
495  guide.SetIgnoreThroughHolePads( ! m_pcb->IsElementVisible( LAYER_PADS_TH ) );
496  guide.SetIgnoreModulesVals( ! m_pcb->IsElementVisible( LAYER_MOD_VALUES ) );
497  guide.SetIgnoreModulesRefs( ! m_pcb->IsElementVisible( LAYER_MOD_REFERENCES ) );
498  guide.SetIgnoreThroughVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
499  guide.SetIgnoreBlindBuriedVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
500  guide.SetIgnoreMicroVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
501  guide.SetIgnoreTracks( ! m_pcb->IsElementVisible( LAYER_TRACKS ) );
502 
503  return guide;
504 }
505 
506 
507 /*
508  * Display the grid status.
509  */
511 {
512  wxString line;
513 
514  line.Printf( "grid X %s Y %s",
515  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
516  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
517 
518  SetStatusText( line, 4 );
519 }
520 
521 
522 /*
523  * Update the status bar information.
524  */
526 {
528 
529  BASE_SCREEN* screen = GetScreen();
530 
531  if( !screen )
532  return;
533 
534  wxString line;
536 
537  if( GetShowPolarCoords() ) // display polar coordinates
538  {
539  double dx = cursorPos.x - screen->m_LocalOrigin.x;
540  double dy = cursorPos.y - screen->m_LocalOrigin.y;
541  double theta = RAD2DEG( atan2( -dy, dx ) );
542  double ro = hypot( dx, dy );
543 
544  line.Printf( wxT( "r %s theta %.3f" ),
545  MessageTextFromValue( GetUserUnits(), ro, false ), theta );
546 
547  SetStatusText( line, 3 );
548  }
549 
550  // Transform absolute coordinates for user origin preferences
551  double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
552  double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
553 
554  // Display absolute coordinates:
555  line.Printf( wxT( "X %s Y %s" ),
556  MessageTextFromValue( GetUserUnits(), userXpos, false ),
557  MessageTextFromValue( GetUserUnits(), userYpos, false ) );
558  SetStatusText( line, 2 );
559 
560  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
561  {
562  // Calculate relative coordinates
563  double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
564  double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
565 
566  // Transform relative coordinates for user origin preferences
567  userXpos = m_originTransforms.ToDisplayRelX( relXpos );
568  userYpos = m_originTransforms.ToDisplayRelY( relYpos );
569 
570  line.Printf( wxT( "dx %s dy %s dist %s" ),
571  MessageTextFromValue( GetUserUnits(), userXpos, false ),
572  MessageTextFromValue( GetUserUnits(), userYpos, false ),
573  MessageTextFromValue( GetUserUnits(), hypot( userXpos, userYpos ), false ) );
574  SetStatusText( line, 3 );
575  }
576 
577  DisplayGridMsg();
578 }
579 
580 
582 {
583  EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
584 
586 }
587 
588 
590 {
592 
593  if( aCfg->m_Window.grid.sizes.empty() )
594  aCfg->m_Window.grid.sizes = aCfg->DefaultGridSizeList();
595 
596  // Currently values read from config file are not used because the user cannot
597  // change this config
598  // if( aCfg->m_Window.zoom_factors.empty() )
599  {
601  }
602 
603  // Some, but not all derived classes have a PCBNEW_SETTINGS.
604  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
605 
606  if( cfg )
607  {
610  }
611 
612  wxASSERT( GetCanvas() );
613 
614  if( GetCanvas() )
615  {
617 
618  if( rs )
619  {
623  }
624  }
625 }
626 
627 
628 SEVERITY PCB_BASE_FRAME::GetSeverity( int aErrorCode ) const
629 {
630  if( aErrorCode >= CLEANUP_FIRST )
631  return RPT_SEVERITY_ACTION;
632 
634 
635  return bds.m_DRCSeverities[ aErrorCode ];
636 }
637 
638 
640 {
642 
643  // Some, but not all derived classes have a PCBNEW_SETTINGS.
644  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
645 
646  if( cfg )
647  {
650  }
651 }
652 
653 
655 {
656  return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
657 }
658 
659 
661 {
662  return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
663 }
664 
666 {
667  wxCHECK( m_settings, nullptr );
668  return &m_settings->m_MagneticItems;
669 }
670 
671 
672 void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
673 {
674  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
675 
678 
680 
681  // The 3D viewer isn't in the Kiway, so send its update manually
682  EDA_3D_VIEWER* viewer = Get3DViewerFrame();
683 
684  if( viewer )
685  viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
686 }
687 
688 
690 {
691  GetScreen()->SetModify();
692  GetScreen()->SetSave();
693 
695 
696  UpdateStatusBar();
697  UpdateMsgPanel();
698 }
699 
700 
702 {
703  return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
704 }
705 
706 
708 {
710 
711  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
712 
713  if( m_toolManager )
714  {
716  GetCanvas()->GetViewControls(), config(), this );
717  }
718 
719  if( m_toolManager )
721 
722  // Transfer latest current display options from legacy to GAL canvas:
723  auto painter = static_cast<KIGFX::PCB_PAINTER*>( canvas->GetView()->GetPainter() );
724  auto settings = painter->GetSettings();
725  auto displ_opts = GetDisplayOptions();
726  settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
727  settings->LoadColors( GetColorSettings() );
728 
729  canvas->GetView()->RecacheAllItems();
731  canvas->StartDrawing();
732 }
733 
734 
736 {
737  bool hcChanged = m_displayOptions.m_ContrastModeDisplay != aOptions.m_ContrastModeDisplay;
738  m_displayOptions = aOptions;
739 
740  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
741  KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
742 
743  view->UpdateDisplayOptions( aOptions );
746 
747  // Vias on a restricted layer set must be redrawn when high contrast mode is changed
748  if( hcChanged )
749  {
751  []( KIGFX::VIEW_ITEM* aItem ) -> bool
752  {
753  if( VIA* via = dynamic_cast<VIA*>( aItem ) )
754  {
755  return via->GetViaType() == VIATYPE::BLIND_BURIED
756  || via->GetViaType() == VIATYPE::MICROVIA;
757  }
758 
759  return false;
760  } );
761  }
762 
763  canvas->Refresh();
764 }
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:792
#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:789
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:125
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:599
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:602
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:1426
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:266
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_ITEM * GetItem(const KIID &aId) override
Fetch an item by KIID.
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:607
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:803
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.
virtual void Update3DView(bool aReloadRequest, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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:600
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:308
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1372
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:1412
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:179
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:584
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
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
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.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
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)
All except INITIAL_ADD.
Definition: view_item.h:58
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)
void ClearBrightened()
Definition: eda_item.h:182
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.
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:202
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
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1543
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
const ZONE_SETTINGS & GetZoneSettings() const
Non-active layers are shown normally (no high-contrast mode)
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1366
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:603
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:270
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:524
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
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:263
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:605
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:189
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
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:149
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:1437
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:106
wxPoint m_AuxOrigin
origin for plot exports
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
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:162
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