KiCad PCB EDA Suite
pcb_base_frame.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-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 
27 #include <kiface_i.h>
28 #include <confirm.h>
29 #include <dialog_helpers.h>
30 #include <pcb_base_frame.h>
31 #include <base_units.h>
32 #include <widgets/msgpanel.h>
33 #include <pgm_base.h>
34 #include <3d_viewer/eda_3d_viewer.h> // To include VIEWER3D_FRAMENAME
36 #include <fp_lib_table.h>
37 #include <pcbnew_id.h>
38 #include <board.h>
39 #include <footprint.h>
40 #include <collectors.h>
41 #include <pcb_draw_panel_gal.h>
42 #include <math/vector2d.h>
43 
44 #include <pcb_painter.h>
46 #include <pcbnew_settings.h>
47 #include <tool/tool_manager.h>
48 #include <tool/tool_dispatcher.h>
49 #include <tools/pcb_actions.h>
50 #include <tool/grid_menu.h>
51 #include "cleanup_item.h"
52 
53 wxDEFINE_EVENT( BOARD_CHANGED, wxCommandEvent );
54 
55 PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
56  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
57  long aStyle, const wxString & aFrameName ) :
58  EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
59  m_pcb( nullptr ),
60  m_originTransforms( *this )
61 {
62  m_settings = static_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
63 }
64 
65 
67 {
68  // Ensure m_canvasType is up to date, to save it in config
70 
71  delete m_pcb;
72 }
73 
74 
76 {
77  return dynamic_cast<EDA_3D_VIEWER*>( FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) ) );
78 }
79 
80 
81 void PCB_BASE_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
82 {
83  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
84 
85  if( draw3DFrame )
86  {
87  if( aTitle )
88  draw3DFrame->SetTitle( *aTitle );
89 
90  draw3DFrame->NewDisplay( aForceReload );
91  }
92 }
93 
94 
96 {
97  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
98 
99  if( draw3DFrame )
100  {
101  draw3DFrame->Redraw();
102  }
103 }
104 
105 
107 {
108  // This is a lazy loading function, it loads the project specific table when
109  // that table is asked for, not before.
110 
112 
113  // its gotta be NULL or a FP_LIB_TABLE, or a bug.
114  wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
115 
116  if( !tbl )
117  {
118  // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
119  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
120  // stack this way, all using the same global fallback table.
121  tbl = new FP_LIB_TABLE( &GFootprintTable );
122 
123  SetElem( ELEM_FPTBL, tbl );
124 
125  wxString projectFpLibTableFileName = FootprintLibTblName();
126 
127  try
128  {
129  tbl->Load( projectFpLibTableFileName );
130  }
131  catch( const IO_ERROR& ioe )
132  {
133  DisplayErrorMessage( nullptr, _( "Error loading project footprint libraries" ),
134  ioe.What() );
135  }
136  }
137 
138  return tbl;
139 }
140 
141 
143 {
144  if( m_pcb != aBoard )
145  {
146  delete m_pcb;
147  m_pcb = aBoard;
148 
149  wxCommandEvent e( BOARD_CHANGED );
150  ProcessEventLocally( e );
151  }
152 }
153 
154 
156 {
157  if( aFootprint )
158  {
159  GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
160 
161  aFootprint->SetFlags(IS_NEW );
162  aFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
163 
164  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
165  // built from a board)
166  if( aFootprint->IsFlipped() )
167  aFootprint->Flip( aFootprint->GetPosition(), m_settings->m_FlipLeftRight );
168 
169  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
170  // it might be stored in another orientation if the lib is an archive built from a board)
171  aFootprint->SetOrientation( 0 );
172  }
173 }
174 
175 
177 {
178  return GetBoard()->GetItem( aId );
179 }
180 
181 
183 {
184  static KIID lastBrightenedItemID( niluuid );
185 
186  BOARD_ITEM* lastItem = GetBoard()->GetItem( lastBrightenedItemID );
187 
188  if( lastItem && lastItem != aItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
189  {
190  lastItem->ClearBrightened();
191 
192  if( lastItem->Type() == PCB_FOOTPRINT_T )
193  {
194  static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
195  [&]( BOARD_ITEM* child )
196  {
197  child->ClearBrightened();
198  } );
199  }
200  else if( lastItem->Type() == PCB_GROUP_T )
201  {
202  static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
203  [&]( BOARD_ITEM* child )
204  {
205  child->ClearBrightened();
206  } );
207  }
208 
209  GetCanvas()->GetView()->Update( lastItem );
210  lastBrightenedItemID = niluuid;
211  GetCanvas()->Refresh();
212  }
213 
214  if( aItem )
215  {
216  aItem->SetBrightened();
217 
218  if( aItem->Type() == PCB_FOOTPRINT_T )
219  {
220  static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
221  [&]( BOARD_ITEM* child )
222  {
223  child->SetBrightened();
224  });
225  }
226  else if( aItem->Type() == PCB_GROUP_T )
227  {
228  static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
229  [&]( BOARD_ITEM* child )
230  {
231  child->SetBrightened();
232  });
233  }
234 
235  GetCanvas()->GetView()->Update( aItem );
236  lastBrightenedItemID = aItem->m_Uuid;
237  FocusOnLocation( aItem->GetFocusPosition() );
238  GetCanvas()->Refresh();
239  }
240 }
241 
242 
243 void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
244 {
245  m_pcb->SetPageSettings( aPageSettings );
246 
247  if( GetScreen() )
248  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
249 }
250 
251 
253 {
254  return m_pcb->GetPageSettings();
255 }
256 
257 
258 const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
259 {
260  // this function is only needed because EDA_DRAW_FRAME is not compiled
261  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
262  // into an application specific source file.
263  return m_pcb->GetPageSettings().GetSizeIU();
264 }
265 
266 
267 const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
268 {
270 }
271 
272 
273 void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
274 {
276 }
277 
278 
279 const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
280 {
282 }
283 
284 
285 const wxPoint PCB_BASE_FRAME::GetUserOrigin() const
286 {
287  auto& displ_opts = GetDisplayOptions();
288  wxPoint origin( 0, 0 );
289 
290  switch( displ_opts.m_DisplayOrigin )
291  {
293  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
294  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID: origin = GetGridOrigin(); break;
295  default: wxASSERT( false ); break;
296  }
297 
298  return origin;
299 }
300 
302 {
303  return m_originTransforms;
304 }
305 
306 
308 {
309  return m_pcb->GetTitleBlock();
310 }
311 
312 
313 void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
314 {
315  m_pcb->SetTitleBlock( aTitleBlock );
316 }
317 
318 
320 {
321  return m_pcb->GetDesignSettings();
322 }
323 
324 
326 {
327  m_drawBgColor= aColor;
328  m_auimgr.Update();
329 }
330 
331 
333 {
335 }
336 
337 
339 {
341 }
342 
343 
345 {
346  return m_pcb->GetPlotOptions();
347 }
348 
349 
351 {
352  m_pcb->SetPlotOptions( aSettings );
353 }
354 
355 
356 EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
357 {
358  EDA_RECT area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
359 
360  if( area.GetWidth() == 0 && area.GetHeight() == 0 )
361  {
362  wxSize pageSize = GetPageSizeIU();
363 
365  {
366  area.SetOrigin( 0, 0 );
367  area.SetEnd( pageSize.x, pageSize.y );
368  }
369  else
370  {
371  area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
372  area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
373  }
374  }
375 
376  return area;
377 }
378 
379 
380 // Virtual function
382 {
383 }
384 
385 
387 {
388  // call my base class
390 
391  // tooltips in toolbars
393 
394  // status bar
395  UpdateMsgPanel();
396 }
397 
398 
400 {
401  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
402 
403  if( !draw3DFrame )
404  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
405 
406  // Raising the window does not show the window on Windows if iconized. This should work
407  // on any platform.
408  if( draw3DFrame->IsIconized() )
409  draw3DFrame->Iconize( false );
410 
411  draw3DFrame->Raise();
412  draw3DFrame->Show( true );
413 
414  // Raising the window does not set the focus on Linux. This should work on any platform.
415  if( wxWindow::FindFocus() != draw3DFrame )
416  draw3DFrame->SetFocus();
417 
418  return draw3DFrame;
419 }
420 
421 
422 // Note: virtual, overridden in PCB_EDIT_FRAME;
424 {
425  PCB_LAYER_ID preslayer = GetActiveLayer();
426  auto& displ_opts = GetDisplayOptions();
427 
428  // Check if the specified layer matches the present layer
429  if( layer == preslayer )
430  return;
431 
432  // Copper layers cannot be selected unconditionally; how many of those layers are
433  // currently enabled needs to be checked.
434  if( IsCopperLayer( layer ) )
435  {
436  // If only one copper layer is enabled, the only such layer that can be selected to
437  // is the "Copper" layer (so the selection of any other copper layer is disregarded).
438  if( m_pcb->GetCopperLayerCount() < 2 )
439  {
440  if( layer != B_Cu )
441  return;
442  }
443 
444  // If more than one copper layer is enabled, the "Copper" and "Component" layers
445  // can be selected, but the total number of copper layers determines which internal
446  // layers are also capable of being selected.
447  else
448  {
449  if( layer != B_Cu && layer != F_Cu && layer >= ( m_pcb->GetCopperLayerCount() - 1 ) )
450  return;
451  }
452  }
453 
454  // Is yet more checking required? E.g. when the layer to be selected is a non-copper
455  // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
456  // ...
457 
458  SetActiveLayer( layer );
459 
460  if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
461  GetCanvas()->Refresh();
462 }
463 
464 
466 {
468  GetCanvas()->GetView() );
469 
470  // account for the globals
472  guide.SetIgnoreMTextsOnBack( ! m_pcb->IsElementVisible( LAYER_MOD_TEXT_BK ) );
473  guide.SetIgnoreMTextsOnFront( ! m_pcb->IsElementVisible( LAYER_MOD_TEXT_FR ) );
474  guide.SetIgnoreModulesOnBack( ! m_pcb->IsElementVisible( LAYER_MOD_BK ) );
475  guide.SetIgnoreModulesOnFront( ! m_pcb->IsElementVisible( LAYER_MOD_FR ) );
476  guide.SetIgnorePadsOnBack( ! m_pcb->IsElementVisible( LAYER_PAD_BK ) );
477  guide.SetIgnorePadsOnFront( ! m_pcb->IsElementVisible( LAYER_PAD_FR ) );
478  guide.SetIgnoreThroughHolePads( ! m_pcb->IsElementVisible( LAYER_PADS_TH ) );
479  guide.SetIgnoreModulesVals( ! m_pcb->IsElementVisible( LAYER_MOD_VALUES ) );
480  guide.SetIgnoreModulesRefs( ! m_pcb->IsElementVisible( LAYER_MOD_REFERENCES ) );
481  guide.SetIgnoreThroughVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
482  guide.SetIgnoreBlindBuriedVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
483  guide.SetIgnoreMicroVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
484  guide.SetIgnoreTracks( ! m_pcb->IsElementVisible( LAYER_TRACKS ) );
485 
486  return guide;
487 }
488 
489 
490 /*
491  * Display the grid status.
492  */
494 {
495  wxString line;
496 
497  line.Printf( "grid X %s Y %s",
498  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
499  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
500 
501  SetStatusText( line, 4 );
502 }
503 
504 
505 /*
506  * Update the status bar information.
507  */
509 {
511 
512  BASE_SCREEN* screen = GetScreen();
513 
514  if( !screen )
515  return;
516 
517  wxString line;
519 
520  if( GetShowPolarCoords() ) // display polar coordinates
521  {
522  double dx = cursorPos.x - screen->m_LocalOrigin.x;
523  double dy = cursorPos.y - screen->m_LocalOrigin.y;
524  double theta = RAD2DEG( atan2( -dy, dx ) );
525  double ro = hypot( dx, dy );
526 
527  line.Printf( wxT( "r %s theta %s" ),
528  MessageTextFromValue( GetUserUnits(), ro, false ),
529  MessageTextFromValue( EDA_UNITS::DEGREES, theta, false ) );
530 
531  SetStatusText( line, 3 );
532  }
533 
534  // Transform absolute coordinates for user origin preferences
535  double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
536  double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
537 
538  // Display absolute coordinates:
539  line.Printf( wxT( "X %s Y %s" ),
540  MessageTextFromValue( GetUserUnits(), userXpos, false ),
541  MessageTextFromValue( GetUserUnits(), userYpos, false ) );
542  SetStatusText( line, 2 );
543 
544  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
545  {
546  // Calculate relative coordinates
547  double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
548  double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
549 
550  // Transform relative coordinates for user origin preferences
551  userXpos = m_originTransforms.ToDisplayRelX( relXpos );
552  userYpos = m_originTransforms.ToDisplayRelY( relYpos );
553 
554  line.Printf( wxT( "dx %s dy %s dist %s" ),
555  MessageTextFromValue( GetUserUnits(), userXpos, false ),
556  MessageTextFromValue( GetUserUnits(), userYpos, false ),
557  MessageTextFromValue( GetUserUnits(), hypot( userXpos, userYpos ), false ) );
558  SetStatusText( line, 3 );
559  }
560 
561  DisplayGridMsg();
562 }
563 
564 
566 {
567  EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
568 
570 }
571 
572 
574 {
576 
577  if( aCfg->m_Window.grid.sizes.empty() )
578  {
579  aCfg->m_Window.grid.sizes = { "1000 mil",
580  "500 mil",
581  "250 mil",
582  "200 mil",
583  "100 mil",
584  "50 mil",
585  "25 mil",
586  "20 mil",
587  "10 mil",
588  "5 mil",
589  "2 mil",
590  "1 mil",
591  "5.0 mm",
592  "2.5 mm",
593  "1.0 mm",
594  "0.5 mm",
595  "0.25 mm",
596  "0.2 mm",
597  "0.1 mm",
598  "0.05 mm",
599  "0.025 mm",
600  "0.01 mm" };
601  }
602 
603  if( aCfg->m_Window.zoom_factors.empty() )
604  {
605  aCfg->m_Window.zoom_factors = { 0.035,
606  0.05,
607  0.08,
608  0.13,
609  0.22,
610  0.35,
611  0.6,
612  1.0,
613  1.5,
614  2.2,
615  3.5,
616  5.0,
617  8.0,
618  13.0,
619  20.0,
620  35.0,
621  50.0,
622  80.0,
623  130.0,
624  220.0,
625  300.0 };
626  }
627 
628  for( double& factor : aCfg->m_Window.zoom_factors )
629  factor = std::min( factor, MAX_ZOOM_FACTOR );
630 
631  // Some, but not all derived classes have a PCBNEW_SETTINGS.
632  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
633 
634  if( cfg )
635  {
638  }
639 
640  wxASSERT( GetCanvas() );
641 
642  if( GetCanvas() )
643  {
645 
646  if( rs )
647  {
651  }
652  }
653 }
654 
655 
656 int PCB_BASE_FRAME::GetSeverity( int aErrorCode ) const
657 {
658  if( aErrorCode >= CLEANUP_FIRST )
659  return RPT_SEVERITY_ACTION;
660 
662 
663  return bds.m_DRCSeverities[ aErrorCode ];
664 }
665 
666 
668 {
670 
671  // Some, but not all derived classes have a PCBNEW_SETTINGS.
672  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
673 
674  if( cfg )
675  {
678  }
679 }
680 
681 
683 {
684  return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
685 }
686 
687 
689 {
690  return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
691 }
692 
694 {
695  wxCHECK( m_settings, nullptr );
696  return &m_settings->m_MagneticItems;
697 }
698 
699 
700 void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
701 {
702  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
703 
706 
708 
709  // The 3D viewer isn't in the Kiway, so send its update manually
710  EDA_3D_VIEWER* viewer = Get3DViewerFrame();
711 
712  if( viewer )
713  viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
714 }
715 
716 
718 {
719  GetScreen()->SetModify();
720  GetScreen()->SetSave();
721 
722  UpdateStatusBar();
723  UpdateMsgPanel();
724 }
725 
726 
728 {
729  return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
730 }
731 
732 
734 {
736 
737  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
738 
739  if( m_toolManager )
740  {
742  GetCanvas()->GetViewControls(), config(), this );
743  }
744 
745  if( m_toolManager )
747 
748  // Transfer latest current display options from legacy to GAL canvas:
749  auto painter = static_cast<KIGFX::PCB_PAINTER*>( canvas->GetView()->GetPainter() );
750  auto settings = painter->GetSettings();
751  auto displ_opts = GetDisplayOptions();
752  settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
753  settings->LoadColors( GetColorSettings() );
754 
755  canvas->GetView()->RecacheAllItems();
757  canvas->StartDrawing();
758 }
759 
760 
762 {
763  bool hcChanged = m_displayOptions.m_ContrastModeDisplay != aOptions.m_ContrastModeDisplay;
764  m_displayOptions = aOptions;
765 
766  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
767  KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
768 
769  view->UpdateDisplayOptions( aOptions );
772 
773  // Vias on a restricted layer set must be redrawn when high contrast mode is changed
774  if( hcChanged )
775  {
777  []( KIGFX::VIEW_ITEM* aItem ) -> bool
778  {
779  if( VIA* via = dynamic_cast<VIA*>( aItem ) )
780  return ( via->GetViaType() == VIATYPE::BLIND_BURIED ||
781  via->GetViaType() == VIATYPE::MICROVIA );
782 
783  return false;
784  } );
785  }
786 
787  canvas->Refresh();
788 }
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:761
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: board.h:763
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Definition: base_units.cpp:123
virtual void SetBoard(BOARD *aBoard)
Function SetBoard sets the m_Pcb member in such as way as to ensure deleting any previous BOARD.
Definition: track.h:354
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: board.h:574
virtual void SetHighContrastLayer(int aLayer)
Function SetHighContrastLayer Takes care of display settings for the given layer to be displayed in h...
void DisplayGridMsg() override
Function DisplayGridMsg()
KIWAY & Kiway() const
Function Kiway returns 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:577
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
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
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
wxPoint m_GridOrigin
origin for grid offsets
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Updates items in the view according to the given flags and condition.
Definition: view.cpp:1431
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:253
void Redraw3Dview()
Request a redraw of 3D-Viewer canvas.
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
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
EDA_ITEM * GetItem(const KIID &aId) override
Fetch an item by KIID.
void SetSave()
Definition: base_screen.h:122
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.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:109
void SetDefaultZoneSettings(const ZONE_SETTINGS &aSettings)
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:581
const EDA_RECT GetBoardEdgesBoundingBox() const
Returns the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:777
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings()
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
FP_LIB_TABLE GFootprintTable
!!!!!!!!!!!!!! This code is obsolete because of the merge into pcbnew, don't bother with it.
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
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:575
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual const wxPoint GetFocusPosition() const
Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rath...
Definition: eda_item.h:333
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1377
double RAD2DEG(double rad)
Definition: trigo.h:218
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1417
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
#define MAX_ZOOM_FACTOR
int GetWidth() const
Definition: eda_rect.h:119
show footprints on back
void SetBrightened()
Definition: eda_item.h:197
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:451
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
const wxPoint GetUserOrigin() const
show footprints values (when texts are visibles)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
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()
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:246
PCBNEW_SETTINGS * GetPcbNewSettings()
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:85
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)
Item needs to be redrawn.
Definition: view_item.h:63
The base class for create windows for drawing purpose.
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Function GetPlotSettings returns 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:102
COLOR4D m_drawBgColor
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
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
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:201
bool ShowPageLimits() const
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:258
void ClearBrightened()
Definition: eda_item.h:200
Classes used in Pcbnew, CvPcb and GerbView.
show footprints on front
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:48
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:553
Definition: kiid.h:44
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
PCB_DISPLAY_OPTIONS handles 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, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:94
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
void SetHighContrastFactor(float aFactor)
Item is being added to the view.
Definition: view_item.h:62
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves 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:118
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:220
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
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:411
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
bool m_showBorderAndTitleBlock
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
void SetEnd(int x, int y)
Definition: eda_rect.h:192
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1423
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
const ZONE_SETTINGS & GetZoneSettings() const
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
Definition: footprint.cpp:1258
T ToDisplayRelY(T aInternalValue) const
Helper dialog and control classes.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns 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
Function GetBoardBoundingBox calculates the bounding box containing all board items (or board edge se...
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:578
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:532
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.
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
std::map< int, int > m_DRCSeverities
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
KICAD_T Type() override
Definition: fp_lib_table.h:108
int GetHeight() const
Definition: eda_rect.h:120
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:50
int GetSeverity(int aErrorCode) const override
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves 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:151
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:284
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:497
bool IsFlipped() const
function IsFlipped
Definition: footprint.h:282
virtual RENDER_SETTINGS * GetSettings()=0
Function GetAdapter Returns 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:173
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
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:48
smd pads, front layer
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:580
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:186
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets 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.
int GetCopperLayerCount() const
Definition: board.cpp:425
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void SetSelectFactor(float aFactor)
const PAGE_INFO & GetPageSettings() const override
void SetHighlightFactor(float aFactor)
EDA_UNITS m_userUnits
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Adds the given footprint to the board.
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
wxPoint GetPosition() const override
Definition: footprint.h:200
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:65
GAL_TYPE GetBackend() const
Function GetBackend Returns 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:120
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:376
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:1323
virtual void Update3DView(bool aForceReload, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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 Move the graphic cursor (crosshair cursor...
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification that common settings are updated.
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
PCB_DISPLAY_OPTIONS m_Display
Rendering engine changes.
Definition: tool_base.h:83
EDA_3D_VIEWER * Get3DViewerFrame()
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
#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
VTBL_ENTRY const wxString FootprintLibTblName() const
Function FootprintLibTblName returns the path and filename of this project's fp-lib-table,...
Definition: project.cpp:146
show footprints references (when texts are visibles)
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:89
PCB_ORIGIN_TRANSFORMS m_originTransforms
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
virtual void UpdateMsgPanel()
Redraw the message panel.
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
const wxPoint & GetAuxOrigin() const