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 <fctsys.h>
28 #include <kiface_i.h>
29 #include <confirm.h>
30 #include <dialog_helpers.h>
31 #include <pcb_base_frame.h>
32 #include <base_units.h>
33 #include <msgpanel.h>
34 #include <pgm_base.h>
35 #include <3d_viewer/eda_3d_viewer.h> // To include VIEWER3D_FRAMENAME
36 #include <pcbnew.h>
38 #include <fp_lib_table.h>
39 #include <pcbnew_id.h>
40 #include <class_board.h>
41 #include <class_module.h>
42 #include <class_drawsegment.h>
43 #include <collectors.h>
44 #include <pcb_draw_panel_gal.h>
45 #include <math/vector2d.h>
46 #include <trigo.h>
47 #include <pcb_painter.h>
49 #include <pcbnew_settings.h>
50 #include <tool/tool_manager.h>
51 #include <tool/tool_dispatcher.h>
52 #include <tools/pcb_actions.h>
53 #include <tool/grid_menu.h>
54 #include "cleanup_item.h"
55 
56 wxDEFINE_EVENT( BOARD_CHANGED, wxCommandEvent );
57 
58 PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
59  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
60  long aStyle, const wxString & aFrameName ) :
61  EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
62  m_Pcb( nullptr ),
63  m_OriginTransforms( *this )
64 {
65  m_Settings = static_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
66 }
67 
68 
70 {
71  // Ensure m_canvasType is up to date, to save it in config
73 
74  delete m_Pcb;
75 }
76 
77 
79 {
80  return dynamic_cast<EDA_3D_VIEWER*>( FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) ) );
81 }
82 
83 
84 void PCB_BASE_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
85 {
86  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
87 
88  if( draw3DFrame )
89  {
90  if( aTitle )
91  draw3DFrame->SetTitle( *aTitle );
92 
93  draw3DFrame->NewDisplay( aForceReload );
94  }
95 }
96 
97 
99 {
100  // This is a lazy loading function, it loads the project specific table when
101  // that table is asked for, not before.
102 
104 
105  // its gotta be NULL or a FP_LIB_TABLE, or a bug.
106  wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
107 
108  if( !tbl )
109  {
110  // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
111  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
112  // stack this way, all using the same global fallback table.
113  tbl = new FP_LIB_TABLE( &GFootprintTable );
114 
115  SetElem( ELEM_FPTBL, tbl );
116 
117  wxString projectFpLibTableFileName = FootprintLibTblName();
118 
119  try
120  {
121  tbl->Load( projectFpLibTableFileName );
122  }
123  catch( const IO_ERROR& ioe )
124  {
125  DisplayErrorMessage( nullptr, _( "Error loading project footprint libraries" ),
126  ioe.What() );
127  }
128  }
129 
130  return tbl;
131 }
132 
133 
135 {
136  if( m_Pcb != aBoard )
137  {
138  delete m_Pcb;
139  m_Pcb = aBoard;
140 
141  wxCommandEvent e( BOARD_CHANGED );
142  ProcessEventLocally( e );
143  }
144 }
145 
146 
148 {
149  if( module )
150  {
151  GetBoard()->Add( module, ADD_MODE::APPEND );
152 
153  module->SetFlags( IS_NEW );
154  module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
155 
156  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
157  // built from a board)
158  if( module->IsFlipped() )
159  module->Flip( module->GetPosition(), m_Settings->m_FlipLeftRight );
160 
161  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
162  // it might be stored in another orientation if the lib is an archive built from a board)
163  module->SetOrientation( 0 );
164  }
165 }
166 
167 
169 {
170  return GetBoard()->GetItem( aId );
171 }
172 
173 
175 {
176  static KIID lastBrightenedItemID( niluuid );
177 
178  BOARD_ITEM* lastItem = GetBoard()->GetItem( lastBrightenedItemID );
179 
180  if( lastItem && lastItem != aItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
181  {
182  lastItem->ClearBrightened();
183 
184  if( lastItem->Type() == PCB_MODULE_T )
185  {
186  static_cast<MODULE*>( lastItem )->RunOnChildren( [&]( BOARD_ITEM* child )
187  {
188  child->ClearBrightened();
189  });
190  }
191  else if( lastItem->Type() == PCB_GROUP_T )
192  {
193  static_cast<PCB_GROUP*>( lastItem )->RunOnChildren( [&] ( BOARD_ITEM* child )
194  {
195  child->ClearBrightened();
196  });
197  }
198 
199  GetCanvas()->GetView()->Update( lastItem );
200  lastBrightenedItemID = niluuid;
201  GetCanvas()->Refresh();
202  }
203 
204  if( aItem )
205  {
206  aItem->SetBrightened();
207 
208  if( aItem->Type() == PCB_MODULE_T )
209  {
210  static_cast<MODULE*>( aItem )->RunOnChildren( [&]( BOARD_ITEM* child )
211  {
212  child->SetBrightened();
213  });
214  }
215  else if( aItem->Type() == PCB_GROUP_T )
216  {
217  static_cast<PCB_GROUP*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* child )
218  {
219  child->SetBrightened();
220  });
221  }
222 
223  GetCanvas()->GetView()->Update( aItem );
224  lastBrightenedItemID = aItem->m_Uuid;
225  FocusOnLocation( aItem->GetFocusPosition() );
226  GetCanvas()->Refresh();
227  }
228 }
229 
230 
231 void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
232 {
233  wxASSERT( m_Pcb );
234  m_Pcb->SetPageSettings( aPageSettings );
235 
236  if( GetScreen() )
237  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
238 }
239 
240 
242 {
243  wxASSERT( m_Pcb );
244  return m_Pcb->GetPageSettings();
245 }
246 
247 
248 const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
249 {
250  wxASSERT( m_Pcb );
251 
252  // this function is only needed because EDA_DRAW_FRAME is not compiled
253  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
254  // into an application specific source file.
255  return m_Pcb->GetPageSettings().GetSizeIU();
256 }
257 
258 
260 {
261  wxASSERT( m_Pcb );
263 }
264 
265 
267 {
268  wxASSERT( m_Pcb );
270 }
271 
272 
274 {
275  wxASSERT( m_Pcb );
277 }
278 
279 
281 {
282  auto& displ_opts = GetDisplayOptions();
283  wxPoint origin( 0, 0 );
284 
285  switch( displ_opts.m_DisplayOrigin )
286  {
288  // No-op
289  break;
291  origin = GetAuxOrigin();
292  break;
294  origin = GetGridOrigin();
295  break;
296  default:
297  wxASSERT( false );
298  break;
299  }
300 
301  return origin;
302 }
303 
305 {
306  return m_OriginTransforms;
307 }
308 
309 
311 {
312  wxASSERT( m_Pcb );
313  return m_Pcb->GetTitleBlock();
314 }
315 
316 
317 void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
318 {
319  wxASSERT( m_Pcb );
320  m_Pcb->SetTitleBlock( aTitleBlock );
321 }
322 
323 
325 {
326  wxASSERT( m_Pcb );
327  return m_Pcb->GetDesignSettings();
328 }
329 
330 
332 {
333  m_drawBgColor= aColor;
334  m_auimgr.Update();
335 }
336 
337 
339 {
340  wxASSERT( m_Pcb );
342 }
343 
344 
346 {
347  wxASSERT( m_Pcb );
349 }
350 
351 
353 {
354  wxASSERT( m_Pcb );
355  return m_Pcb->GetPlotOptions();
356 }
357 
358 
360 {
361  wxASSERT( m_Pcb );
362  m_Pcb->SetPlotOptions( aSettings );
363 }
364 
365 
366 EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
367 {
368  wxASSERT( m_Pcb );
369 
370  EDA_RECT area = aBoardEdgesOnly ? m_Pcb->GetBoardEdgesBoundingBox() : m_Pcb->GetBoundingBox();
371 
372  if( area.GetWidth() == 0 && area.GetHeight() == 0 )
373  {
374  wxSize pageSize = GetPageSizeIU();
375 
377  {
378  area.SetOrigin( 0, 0 );
379  area.SetEnd( pageSize.x, pageSize.y );
380  }
381  else
382  {
383  area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
384  area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
385  }
386  }
387 
388  return area;
389 }
390 
391 
392 // Virtual function
394 {
395 }
396 
397 
399 {
400  // call my base class
402 
403  // tooltips in toolbars
405 
406  // status bar
407  UpdateMsgPanel();
408 }
409 
410 
412 {
413  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
414 
415  if( !draw3DFrame )
416  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
417 
418  // Raising the window does not show the window on Windows if iconized. This should work
419  // on any platform.
420  if( draw3DFrame->IsIconized() )
421  draw3DFrame->Iconize( false );
422 
423  draw3DFrame->Raise();
424  draw3DFrame->Show( true );
425 
426  // Raising the window does not set the focus on Linux. This should work on any platform.
427  if( wxWindow::FindFocus() != draw3DFrame )
428  draw3DFrame->SetFocus();
429 
430  return draw3DFrame;
431 }
432 
433 
434 // Note: virtual, overridden in PCB_EDIT_FRAME;
436 {
437  PCB_LAYER_ID preslayer = GetActiveLayer();
438  auto& displ_opts = GetDisplayOptions();
439 
440  // Check if the specified layer matches the present layer
441  if( layer == preslayer )
442  return;
443 
444  // Copper layers cannot be selected unconditionally; how many of those layers are
445  // currently enabled needs to be checked.
446  if( IsCopperLayer( layer ) )
447  {
448  // If only one copper layer is enabled, the only such layer that can be selected to
449  // is the "Copper" layer (so the selection of any other copper layer is disregarded).
450  if( m_Pcb->GetCopperLayerCount() < 2 )
451  {
452  if( layer != B_Cu )
453  return;
454  }
455 
456  // If more than one copper layer is enabled, the "Copper" and "Component" layers
457  // can be selected, but the total number of copper layers determines which internal
458  // layers are also capable of being selected.
459  else
460  {
461  if( layer != B_Cu && layer != F_Cu && layer >= ( m_Pcb->GetCopperLayerCount() - 1 ) )
462  return;
463  }
464  }
465 
466  // Is yet more checking required? E.g. when the layer to be selected is a non-copper
467  // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
468  // ...
469 
470  SetActiveLayer( layer );
471 
472  if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
473  GetCanvas()->Refresh();
474 }
475 
476 
478 {
480  GetCanvas()->GetView() );
481 
482  // account for the globals
484  guide.SetIgnoreMTextsOnBack( ! m_Pcb->IsElementVisible( LAYER_MOD_TEXT_BK ) );
485  guide.SetIgnoreMTextsOnFront( ! m_Pcb->IsElementVisible( LAYER_MOD_TEXT_FR ) );
486  guide.SetIgnoreModulesOnBack( ! m_Pcb->IsElementVisible( LAYER_MOD_BK ) );
487  guide.SetIgnoreModulesOnFront( ! m_Pcb->IsElementVisible( LAYER_MOD_FR ) );
488  guide.SetIgnorePadsOnBack( ! m_Pcb->IsElementVisible( LAYER_PAD_BK ) );
489  guide.SetIgnorePadsOnFront( ! m_Pcb->IsElementVisible( LAYER_PAD_FR ) );
490  guide.SetIgnoreThroughHolePads( ! m_Pcb->IsElementVisible( LAYER_PADS_TH ) );
491  guide.SetIgnoreModulesVals( ! m_Pcb->IsElementVisible( LAYER_MOD_VALUES ) );
492  guide.SetIgnoreModulesRefs( ! m_Pcb->IsElementVisible( LAYER_MOD_REFERENCES ) );
493  guide.SetIgnoreThroughVias( ! m_Pcb->IsElementVisible( LAYER_VIAS ) );
494  guide.SetIgnoreBlindBuriedVias( ! m_Pcb->IsElementVisible( LAYER_VIAS ) );
495  guide.SetIgnoreMicroVias( ! m_Pcb->IsElementVisible( LAYER_VIAS ) );
496  guide.SetIgnoreTracks( ! m_Pcb->IsElementVisible( LAYER_TRACKS ) );
497 
498  return guide;
499 }
500 
501 
502 /*
503  * Display the grid status.
504  */
506 {
507  wxString line;
508  wxString gridformatter;
509 
510  switch( m_userUnits )
511  {
512  case EDA_UNITS::INCHES: gridformatter = "grid X %.6f Y %.6f"; break;
513  case EDA_UNITS::MILLIMETRES: gridformatter = "grid X %.6f Y %.6f"; break;
514  default: gridformatter = "grid X %f Y %f"; break;
515  }
516 
517  double grid_x = To_User_Unit( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x );
518  double grid_y = To_User_Unit( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y );
519  line.Printf( gridformatter, grid_x, grid_y );
520 
521  SetStatusText( line, 4 );
522 }
523 
524 
525 /*
526  * Update the status bar information.
527  */
529 {
531 
532  BASE_SCREEN* screen = GetScreen();
533 
534  if( !screen )
535  return;
536 
537  wxString line;
539 
540  if( GetShowPolarCoords() ) // display polar coordinates
541  {
542  double dx = cursorPos.x - screen->m_LocalOrigin.x;
543  double dy = cursorPos.y - screen->m_LocalOrigin.y;
544  double theta = RAD2DEG( atan2( -dy, dx ) );
545  double ro = hypot( dx, dy );
546  wxString formatter;
547 
548  switch( GetUserUnits() )
549  {
550  case EDA_UNITS::INCHES:
551  formatter = wxT( "r %.6f theta %.1f" );
552  break;
554  formatter = wxT( "r %.6f theta %.1f" );
555  break;
556  case EDA_UNITS::UNSCALED:
557  formatter = wxT( "r %f theta %f" );
558  break;
559  default: wxASSERT( false ); break;
560  }
561 
562  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
563 
564  SetStatusText( line, 3 );
565  }
566 
567  // Transform absolute coordinates for user origin preferences
568  double userXpos = m_OriginTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
569  double userYpos = m_OriginTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
570 
571  // Display absolute coordinates:
572  double dXpos = To_User_Unit( GetUserUnits(), userXpos );
573  double dYpos = To_User_Unit( GetUserUnits(), userYpos );
574 
575  // The following sadly is an if Eeschema/if Pcbnew
576  wxString absformatter;
577  wxString locformatter;
578 
579  switch( GetUserUnits() )
580  {
581  case EDA_UNITS::INCHES:
582  absformatter = "X %.6f Y %.6f";
583  locformatter = "dx %.6f dy %.6f dist %.4f";
584  break;
585 
587  absformatter = "X %.6f Y %.6f";
588  locformatter = "dx %.6f dy %.6f dist %.3f";
589  break;
590 
591  case EDA_UNITS::UNSCALED:
592  absformatter = "X %f Y %f";
593  locformatter = "dx %f dy %f dist %f";
594  break;
595 
596  default:
597  wxASSERT( false );
598  break;
599  }
600 
601  line.Printf( absformatter, dXpos, dYpos );
602  SetStatusText( line, 2 );
603 
604  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
605  {
606  // Calculate relative coordinates
607  double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
608  double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
609 
610  // Transform relative coordinates for user origin preferences
611  userXpos = m_OriginTransforms.ToDisplayRelX( relXpos );
612  userYpos = m_OriginTransforms.ToDisplayRelY( relYpos );
613 
614  // Display relative coordinates:
615  dXpos = To_User_Unit( GetUserUnits(), userXpos );
616  dYpos = To_User_Unit( GetUserUnits(), userYpos );
617 
618  // We already decided the formatter above
619  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
620  SetStatusText( line, 3 );
621  }
622 
623  DisplayGridMsg();
624 }
625 
626 
628 {
629  EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
630 
631  // Notify all tools the units have changed
632  if( m_toolManager )
634 
636 }
637 
638 
640 {
642 
643  if( aCfg->m_Window.grid.sizes.empty() )
644  {
645  aCfg->m_Window.grid.sizes = { "1000 mil",
646  "500 mil",
647  "250 mil",
648  "200 mil",
649  "100 mil",
650  "50 mil",
651  "25 mil",
652  "20 mil",
653  "10 mil",
654  "5 mil",
655  "2 mil",
656  "1 mil",
657  "5.0 mm",
658  "2.5 mm",
659  "1.0 mm",
660  "0.5 mm",
661  "0.25 mm",
662  "0.2 mm",
663  "0.1 mm",
664  "0.05 mm",
665  "0.025 mm",
666  "0.01 mm" };
667  }
668 
669  if( aCfg->m_Window.zoom_factors.empty() )
670  {
671  aCfg->m_Window.zoom_factors = { 0.035,
672  0.05,
673  0.08,
674  0.13,
675  0.22,
676  0.35,
677  0.6,
678  1.0,
679  1.5,
680  2.2,
681  3.5,
682  5.0,
683  8.0,
684  13.0,
685  20.0,
686  35.0,
687  50.0,
688  80.0,
689  130.0,
690  220.0,
691  300.0 };
692  }
693 
694  for( double& factor : aCfg->m_Window.zoom_factors )
695  factor = std::min( factor, MAX_ZOOM_FACTOR );
696 
697  // Some, but not all derived classes have a PCBNEW_SETTINGS.
698  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
699 
700  if( cfg )
701  {
704  }
705 
706  wxASSERT( GetCanvas() );
707 
708  if( GetCanvas() )
709  {
711 
712  if( rs )
713  {
717  }
718  }
719 }
720 
721 
722 int PCB_BASE_FRAME::GetSeverity( int aErrorCode ) const
723 {
724  if( aErrorCode >= CLEANUP_FIRST )
725  return RPT_SEVERITY_ACTION;
726 
728 
729  return bds.m_DRCSeverities[ aErrorCode ];
730 }
731 
732 
734 {
736 
737  // Some, but not all derived classes have a PCBNEW_SETTINGS.
738  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
739 
740  if( cfg )
741  {
744  }
745 }
746 
747 
749 {
750  return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
751 }
752 
753 
755 {
756  return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
757 }
758 
760 {
761  wxCHECK( m_Settings, nullptr );
762  return &m_Settings->m_MagneticItems;
763 }
764 
765 
766 void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
767 {
768  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
769 
771 
773 
774  // The 3D viewer isn't in the Kiway, so send its update manually
775  EDA_3D_VIEWER* viewer = Get3DViewerFrame();
776 
777  if( viewer )
778  viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
779 }
780 
781 
783 {
784  GetScreen()->SetModify();
785  GetScreen()->SetSave();
786 
787  UpdateStatusBar();
788  UpdateMsgPanel();
789 }
790 
791 
793 {
794  return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
795 }
796 
797 
799 {
801 
802  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
803 
804  if( m_toolManager )
805  {
807  GetCanvas()->GetViewControls(), config(), this );
808  }
809 
810  if( m_toolManager )
812 
813  // Transfer latest current display options from legacy to GAL canvas:
814  auto painter = static_cast<KIGFX::PCB_PAINTER*>( canvas->GetView()->GetPainter() );
815  auto settings = painter->GetSettings();
816  auto displ_opts = GetDisplayOptions();
817  settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
818  settings->LoadColors( GetColorSettings() );
819 
820  canvas->GetView()->RecacheAllItems();
822  canvas->StartDrawing();
823 }
824 
825 
827 {
828  m_DisplayOptions = aOptions;
829 
830  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
831  KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
832 
833  view->UpdateDisplayOptions( aOptions );
836 
837  canvas->Refresh();
838 }
double To_User_Unit(EDA_UNITS aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:92
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: class_board.h:760
virtual void SetBoard(BOARD *aBoard)
Function SetBoard sets the m_Pcb member in such as way as to ensure deleting any previous BOARD.
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:552
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: class_board.h:555
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 ...
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
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 DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
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.
virtual void AddModuleToBoard(MODULE *module)
Adds the given module to the board.
void SetSave()
Definition: base_screen.h:102
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:302
multilayer pads, usually with holes
virtual void OnDisplayOptionsChanged()
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
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,...
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: class_board.h:559
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:772
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: class_board.h:553
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: base_struct.h:345
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1395
double RAD2DEG(double rad)
Definition: trigo.h:220
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
void SetBrightened()
Definition: base_struct.h:209
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of ckeck tools.
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
const wxPoint GetUserOrigin() const
show modules values (when texts are visibles)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:537
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
static TOOL_ACTION updateUnits
Definition: pcb_actions.h:418
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:248
PCBNEW_SETTINGS * GetPcbNewSettings()
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
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
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
BOARD_ITEM * GetItem(const KIID &aID)
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:199
bool ShowPageLimits() const
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:260
void ClearBrightened()
Definition: base_struct.h:212
Classes used in Pcbnew, CvPcb and GerbView.
show modules on front
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
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:49
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: common.h:68
class MODULE, a footprint
Definition: typeinfo.h:89
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:
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
void SetHighContrastFactor(float aFactor)
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:117
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
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()
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:43
void SetEnd(int x, int y)
Definition: eda_rect.h:192
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
const ZONE_SETTINGS & GetZoneSettings() const
KIID niluuid(0)
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.
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 SetPosition(const wxPoint &aPos) override
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: class_board.h:556
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:546
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:52
int GetSeverity(int aErrorCode) const override
PCB_DISPLAY_OPTIONS m_DisplayOptions
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)
void SetOrientation(double aNewAngle)
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
const KIID m_Uuid
Definition: base_struct.h:162
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:286
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
PCB_ORIGIN_TRANSFORMS m_OriginTransforms
PCBNEW_SETTINGS * m_Settings
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:171
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:50
smd pads, front layer
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:558
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.
Class to handle a graphic segment.
A class to perform either relative or absolute display origin transforms for a single axis of a point...
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
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
Function GetCopperLayerCount.
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
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
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)
Function IsCopperLayer 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.
wxPoint GetPosition() const override
Definition: class_module.h:219
void UpdateStatusBar() override
Update the status bar information.
ZONE_SETTINGS & GetDefaultZoneSettings()
BOARD * GetBoard() const
void SetModify()
Definition: base_screen.h:100
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:390
MAGNETIC_SETTINGS m_MagneticItems
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
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)
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:148
show modules 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:62
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
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:99
const wxPoint & GetAuxOrigin() const