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, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
8 * Copyright (C) 2022 CERN
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
30#include <boost/version.hpp>
31
32#if BOOST_VERSION >= 106700
33#include <boost/uuid/entropy_error.hpp>
34#endif
35
36#include <kiface_base.h>
37#include <confirm.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_frame.h> // To include VIEWER3D_FRAMENAME
44#include <pcbnew_settings.h>
45#include <fp_lib_table.h>
46#include <pcbnew_id.h>
47#include <board.h>
48#include <footprint.h>
49#include <collectors.h>
50#include <pcb_draw_panel_gal.h>
51#include <math/vector2d.h>
52#include <pcb_group.h>
53
54#include <pcb_painter.h>
57#include <tool/tool_manager.h>
59#include <tools/pcb_actions.h>
60#include <tool/grid_menu.h>
61#include "cleanup_item.h"
62#include <zoom_defines.h>
64
65#if defined( KICAD_USE_3DCONNEXION )
67#endif
68
71
72wxDEFINE_EVENT( BOARD_CHANGED, wxCommandEvent );
73
74PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
75 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
76 long aStyle, const wxString& aFrameName ) :
77 EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, pcbIUScale ),
78 m_pcb( nullptr ),
79 m_originTransforms( *this ),
80 m_spaceMouse( nullptr )
81{
82}
83
84
86{
87#if defined( KICAD_USE_3DCONNEXION )
88 delete m_spaceMouse;
89#endif
90
91 // Ensure m_canvasType is up to date, to save it in config
93
94 delete m_pcb;
95 m_pcb = nullptr;
96}
97
98
99bool PCB_BASE_FRAME::canCloseWindow( wxCloseEvent& aEvent )
100{
101 // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
102 // board.
103 wxWindow* viewer3D = Get3DViewerFrame();
104
105 if( viewer3D )
106 viewer3D->Close( true );
107
108 // Similarly, wxConvBrokenFileNames uses some statically allocated variables that make it
109 // crash when run later from a d'tor.
110 Prj().Cleanup3DCache();
111
112 return true;
113}
114
115
116void PCB_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
117{
119
120#if defined( KICAD_USE_3DCONNEXION )
121 if( m_spaceMouse != nullptr )
122 {
123 m_spaceMouse->SetFocus( aEvent.GetActive() );
124 }
125#endif
126}
127
128
129void PCB_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
130{
132
133#if defined( KICAD_USE_3DCONNEXION )
134 if( m_spaceMouse != nullptr && aEvent.IsIconized() )
135 {
136 m_spaceMouse->SetFocus( false );
137 }
138#endif
139}
140
141
143{
144 wxWindow* frame = FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) );
145 return dynamic_cast<EDA_3D_VIEWER_FRAME*>( frame );
146}
147
148
149void PCB_BASE_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
150{
151 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
152
153 if( draw3DFrame )
154 {
155 if( aTitle )
156 draw3DFrame->SetTitle( *aTitle );
157
158 if( aMarkDirty )
159 draw3DFrame->ReloadRequest();
160
161 if( aRefresh )
162 draw3DFrame->Redraw();
163 }
164}
165
166
168{
169 // This is a lazy loading function, it loads the project specific table when
170 // that table is asked for, not before.
171
173
174 // its gotta be NULL or a FP_LIB_TABLE, or a bug.
175 wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
176
177 if( !tbl )
178 {
179 // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
180 // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
181 // stack this way, all using the same global fallback table.
182 tbl = new FP_LIB_TABLE( &GFootprintTable );
183
184 SetElem( ELEM_FPTBL, tbl );
185
186 wxString projectFpLibTableFileName = FootprintLibTblName();
187
188 try
189 {
190 tbl->Load( projectFpLibTableFileName );
191 }
192 catch( const IO_ERROR& ioe )
193 {
194 DisplayErrorMessage( nullptr, _( "Error loading project footprint libraries." ),
195 ioe.What() );
196 }
197 catch( ... )
198 {
199 DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ) );
200 }
201 }
202
203 return tbl;
204}
205
206
208{
209 if( m_pcb != aBoard )
210 {
211 delete m_pcb;
212 m_pcb = aBoard;
213
214 if( GetBoard() && GetCanvas() )
215 {
217
218 if( rs )
219 {
220 rs->SetDashLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineDashRatio() );
221 rs->SetGapLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineGapRatio() );
222 }
223 }
224
225 wxCommandEvent e( BOARD_CHANGED );
226 ProcessEventLocally( e );
227 }
228}
229
230
232{
233 if( aFootprint )
234 {
235 GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
236
237 aFootprint->SetFlags( IS_NEW );
238 aFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
239
240 // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
241 // built from a board)
242 if( aFootprint->IsFlipped() )
243 aFootprint->Flip( aFootprint->GetPosition(), GetPcbNewSettings()->m_FlipLeftRight );
244
245 // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
246 // it might be stored in another orientation if the lib is an archive built from a board)
247 aFootprint->SetOrientation( ANGLE_0 );
248
249 UpdateUserUnits( aFootprint );
250 }
251}
252
253
254void PCB_BASE_FRAME::UpdateUserUnits( BOARD_ITEM* aItem, bool* aSelectedItemsModified )
255{
256 EDA_UNITS units = GetUserUnits();
257 KIGFX::VIEW* view = GetCanvas()->GetView();
258
259 INSPECTOR_FUNC inspector =
260 [&]( EDA_ITEM* descendant, void* aTestData )
261 {
262 PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( descendant );
263
264 if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
265 {
266 dimension->SetUnits( units );
267 dimension->Update();
268
269 if( aSelectedItemsModified && dimension->IsSelected() )
270 *aSelectedItemsModified = true;
271
272 view->Update( dimension );
273 }
274
276 };
277
278 aItem->Visit( inspector, nullptr, { PCB_DIM_ALIGNED_T,
287}
288
289
291{
292 return GetBoard()->GetItem( aId );
293}
294
295
297{
298 std::vector<BOARD_ITEM*> items;
299
300 if( aItem )
301 items.push_back( aItem );
302
303 FocusOnItems( items, aLayer );
304}
305
306
307void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID aLayer )
308{
309 static std::vector<KIID> lastBrightenedItemIDs;
310
311 BOARD_ITEM* lastItem = nullptr;
312
313 for( KIID lastBrightenedItemID : lastBrightenedItemIDs )
314 {
317 #if BOOST_VERSION >= 106700
318 try
319 {
320 lastItem = GetBoard()->GetItem( lastBrightenedItemID );
321 }
322 catch( const boost::uuids::entropy_error& )
323 {
324 wxLogError( wxT( "A Boost UUID entropy exception was thrown in %s:%s." ),
325 __FILE__, __FUNCTION__ );
326 }
327 #else
328 lastItem = GetBoard()->GetItem( lastBrightenedItemID );
329 #endif
330
331 if( lastItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
332 {
333 lastItem->ClearBrightened();
334
335 if( lastItem->Type() == PCB_FOOTPRINT_T )
336 {
337 static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
338 [&]( BOARD_ITEM* child )
339 {
340 child->ClearBrightened();
341 } );
342 }
343 else if( lastItem->Type() == PCB_GROUP_T )
344 {
345 static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
346 [&]( BOARD_ITEM* child )
347 {
348 child->ClearBrightened();
349 } );
350 }
351
352 GetCanvas()->GetView()->Update( lastItem );
353 lastBrightenedItemID = niluuid;
354 GetCanvas()->Refresh();
355 }
356 }
357
358 lastBrightenedItemIDs.clear();
359
360 if( aItems.empty() )
361 return;
362
363 VECTOR2I focusPt;
364 KIGFX::VIEW* view = GetCanvas()->GetView();
365 SHAPE_POLY_SET viewportPoly( view->GetViewport() );
366
367 for( wxWindow* dialog : findDialogs() )
368 {
369 wxPoint dialogPos = GetCanvas()->ScreenToClient( dialog->GetScreenPosition() );
370 SHAPE_POLY_SET dialogPoly( BOX2D( view->ToWorld( dialogPos, true ),
371 view->ToWorld( dialog->GetSize(), false ) ) );
372
373 try
374 {
375 viewportPoly.BooleanSubtract( dialogPoly, SHAPE_POLY_SET::PM_FAST );
376 }
377 catch( const ClipperLib::clipperException& exc )
378 {
379 // This may be overkill and could be an assertion but we are more likely to
380 // find any clipper errors this way.
381 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
382 }
383 }
384
385 SHAPE_POLY_SET itemPoly, clippedPoly;
386
387 for( BOARD_ITEM* item : aItems )
388 {
389 if( item && item != DELETED_BOARD_ITEM::GetInstance() )
390 {
391 item->SetBrightened();
392
393 if( item->Type() == PCB_FOOTPRINT_T )
394 {
395 static_cast<FOOTPRINT*>( item )->RunOnChildren(
396 [&]( BOARD_ITEM* child )
397 {
398 child->SetBrightened();
399 });
400 }
401 else if( item->Type() == PCB_GROUP_T )
402 {
403 static_cast<PCB_GROUP*>( item )->RunOnChildren(
404 [&]( BOARD_ITEM* child )
405 {
406 child->SetBrightened();
407 });
408 }
409
410 GetCanvas()->GetView()->Update( item );
411 lastBrightenedItemIDs.push_back( item->m_Uuid );
412
413 // Focus on the object's location. Prefer a visible part of the object to its anchor
414 // in order to keep from scrolling around.
415
416 focusPt = item->GetPosition();
417
418 if( aLayer == UNDEFINED_LAYER )
419 aLayer = item->GetLayerSet().Seq()[0];
420
421 switch( item->Type() )
422 {
423 case PCB_FOOTPRINT_T:
424 try
425 {
426 itemPoly = static_cast<FOOTPRINT*>( item )->GetBoundingHull();
427 }
428 catch( const ClipperLib::clipperException& exc )
429 {
430 // This may be overkill and could be an assertion but we are more likely to
431 // find any clipper errors this way.
432 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
433 }
434
435 break;
436
437 case PCB_PAD_T:
438 case PCB_MARKER_T:
439 case PCB_VIA_T:
440 FocusOnLocation( item->GetFocusPosition() );
441 GetCanvas()->Refresh();
442 return;
443
444 case PCB_SHAPE_T:
445 case PCB_TEXT_T:
446 case PCB_TEXTBOX_T:
447 case PCB_FP_TEXT_T:
448 case PCB_FP_TEXTBOX_T:
449 case PCB_FP_SHAPE_T:
450 case PCB_FP_ZONE_T:
451 case PCB_TRACE_T:
452 case PCB_ARC_T:
454 case PCB_DIM_LEADER_T:
455 case PCB_DIM_CENTER_T:
456 case PCB_DIM_RADIAL_T:
463 item->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ),
464 ERROR_INSIDE );
465 break;
466
467 case PCB_ZONE_T:
468 {
469 ZONE* zone = static_cast<ZONE*>( item );
470 #if 0
471 // Using the filled area shapes to find a Focus point can give good results, but
472 // unfortunately the calculations are highly time consuming, even for not very
473 // large areas (can be easily a few minutes for large areas).
474 // so we used only the zone outline that usually do not have too many vertices.
475 zone->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ),
476 ERROR_INSIDE );
477
478 if( itemPoly.IsEmpty() )
479 itemPoly = *zone->Outline();
480 #else
481 // much faster calculation time when using only the zone outlines
482 itemPoly = *zone->Outline();
483 #endif
484
485 break;
486 }
487
488 default:
489 {
490 BOX2I item_bbox = item->GetBoundingBox();
491 itemPoly.NewOutline();
492 itemPoly.Append( item_bbox.GetOrigin() );
493 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(), 0 ) );
494 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( 0, item_bbox.GetHeight() ) );
495 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(),
496 item_bbox.GetHeight() ) );
497 break;
498 }
499 }
500
501 try
502 {
503 clippedPoly.BooleanIntersection( itemPoly, viewportPoly, SHAPE_POLY_SET::PM_FAST );
504 }
505 catch( const ClipperLib::clipperException& exc )
506 {
507 // This may be overkill and could be an assertion but we are more likely to
508 // find any clipper errors this way.
509 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
510 }
511
512 if( !clippedPoly.IsEmpty() )
513 itemPoly = clippedPoly;
514 }
515 }
516
517 /*
518 * Perform a step-wise deflate to find the visual-center-of-mass
519 */
520
521 BOX2I bbox = itemPoly.BBox();
522 int step = std::min( bbox.GetWidth(), bbox.GetHeight() ) / 10;
523
524 while( !itemPoly.IsEmpty() )
525 {
526 focusPt = itemPoly.BBox().Centre();
527
528 try
529 {
531 }
532 catch( const ClipperLib::clipperException& exc )
533 {
534 // This may be overkill and could be an assertion but we are more likely to
535 // find any clipper errors this way.
536 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
537 }
538 }
539
540 FocusOnLocation( focusPt );
541
542 GetCanvas()->Refresh();
543}
544
545
547{
548 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
549
550 if( view && GetBoard()->m_SolderMask && view->HasItem( GetBoard()->m_SolderMask ) )
551 view->Remove( GetBoard()->m_SolderMask );
552}
553
554
556{
557 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
558
559 if( view && GetBoard()->m_SolderMask )
560 {
561 if( view->HasItem( GetBoard()->m_SolderMask ) )
562 view->Remove( GetBoard()->m_SolderMask );
563
564 view->Add( GetBoard()->m_SolderMask );
565 }
566}
567
568
569void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
570{
571 m_pcb->SetPageSettings( aPageSettings );
572
573 if( GetScreen() )
575}
576
577
579{
580 return m_pcb->GetPageSettings();
581}
582
583
585{
586 // this function is only needed because EDA_DRAW_FRAME is not compiled
587 // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
588 // into an application specific source file.
590}
591
592
594{
596}
597
598
600{
602}
603
604
606{
608}
609
610
612{
613 VECTOR2I origin( 0, 0 );
614
615 switch( GetPcbNewSettings()->m_Display.m_DisplayOrigin )
616 {
618 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
620 default: wxASSERT( false ); break;
621 }
622
623 return origin;
624}
625
627{
628 return m_originTransforms;
629}
630
631
633{
634 return m_pcb->GetTitleBlock();
635}
636
637
639{
640 m_pcb->SetTitleBlock( aTitleBlock );
641}
642
643
645{
646 return m_pcb->GetDesignSettings();
647}
648
649
651{
652 m_drawBgColor= aColor;
653 m_auimgr.Update();
654}
655
656
658{
660}
661
662
664{
666}
667
668
670{
671 return m_pcb->GetPlotOptions();
672}
673
674
676{
677 m_pcb->SetPlotOptions( aSettings );
678}
679
680
681BOX2I PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
682{
683 BOX2I area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
684
685 if( area.GetWidth() == 0 && area.GetHeight() == 0 )
686 {
687 wxSize pageSize = GetPageSizeIU();
688
690 {
691 area.SetOrigin( 0, 0 );
692 area.SetEnd( pageSize.x, pageSize.y );
693 }
694 else
695 {
696 area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
697 area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
698 }
699 }
700
701 return area;
702}
703
704
705// Virtual function
707{
708}
709
710
712{
713 // call my base class
715
716 // tooltips in toolbars
718}
719
720
722{
723 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
724
725 if( !draw3DFrame )
726 draw3DFrame = new EDA_3D_VIEWER_FRAME( &Kiway(), this, _( "3D Viewer" ) );
727
728 // Raising the window does not show the window on Windows if iconized. This should work
729 // on any platform.
730 if( draw3DFrame->IsIconized() )
731 draw3DFrame->Iconize( false );
732
733 draw3DFrame->Raise();
734 draw3DFrame->Show( true );
735
736 // Raising the window does not set the focus on Linux. This should work on any platform.
737 if( wxWindow::FindFocus() != draw3DFrame )
738 draw3DFrame->SetFocus();
739
740 // Allocate a slice of time to display the 3D frame
741 // a call to wxSafeYield() should be enough (and better), but on Linux we need
742 // to call wxYield()
743 // otherwise the activity messages are not displayed during the first board loading
744 wxYield();
745
746 // Note, the caller is responsible to load/update the board 3D view.
747 // after frame creation the board is not automatically created.
748
749 return draw3DFrame;
750}
751
752
754{
755 PCB_LAYER_ID preslayer = GetActiveLayer();
756 auto& displ_opts = GetDisplayOptions();
757
758 // Check if the specified layer matches the present layer
759 if( layer == preslayer )
760 return;
761
762 // Copper layers cannot be selected unconditionally; how many of those layers are
763 // currently enabled needs to be checked.
764 if( IsCopperLayer( layer ) )
765 {
766 // If only one copper layer is enabled, the only such layer that can be selected to
767 // is the "Copper" layer (so the selection of any other copper layer is disregarded).
768 if( m_pcb->GetCopperLayerCount() < 2 )
769 {
770 if( layer != B_Cu )
771 return;
772 }
773
774 // If more than one copper layer is enabled, the "Copper" and "Component" layers
775 // can be selected, but the total number of copper layers determines which internal
776 // layers are also capable of being selected.
777 else
778 {
779 if( layer != B_Cu && layer != F_Cu && layer >= ( m_pcb->GetCopperLayerCount() - 1 ) )
780 return;
781 }
782 }
783
784 // Is yet more checking required? E.g. when the layer to be selected is a non-copper
785 // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
786 // ...
787
788 SetActiveLayer( layer );
789
790 if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
791 GetCanvas()->Refresh();
792}
793
794
796{
798 GetCanvas()->GetView() );
799
800 // account for the globals
815
816 return guide;
817}
818
819
821{
822 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
823 wxString line;
824
825 line.Printf( wxT( "grid X %s Y %s" ),
826 MessageTextFromValue( gridSize.x, false ),
827 MessageTextFromValue( gridSize.y, false ) );
828
829 SetStatusText( line, 4 );
830}
831
832
834{
836
837 BASE_SCREEN* screen = GetScreen();
838
839 if( !screen )
840 return;
841
842 wxString line;
844
845 if( GetShowPolarCoords() ) // display polar coordinates
846 {
847 double dx = cursorPos.x - screen->m_LocalOrigin.x;
848 double dy = cursorPos.y - screen->m_LocalOrigin.y;
849 double theta = RAD2DEG( atan2( -dy, dx ) );
850 double ro = hypot( dx, dy );
851
852 line.Printf( wxT( "r %s theta %.3f" ),
853 MessageTextFromValue( ro, false ),
854 theta );
855
856 SetStatusText( line, 3 );
857 }
858
859 // Transform absolute coordinates for user origin preferences
860 double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
861 double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
862
863 // Display absolute coordinates:
864 line.Printf( wxT( "X %s Y %s" ),
865 MessageTextFromValue( userXpos, false ),
866 MessageTextFromValue( userYpos, false ) );
867 SetStatusText( line, 2 );
868
869 if( !GetShowPolarCoords() ) // display relative cartesian coordinates
870 {
871 // Calculate relative coordinates
872 double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
873 double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
874
875 // Transform relative coordinates for user origin preferences
876 userXpos = m_originTransforms.ToDisplayRelX( relXpos );
877 userYpos = m_originTransforms.ToDisplayRelY( relYpos );
878
879 line.Printf( wxT( "dx %s dy %s dist %s" ),
880 MessageTextFromValue( userXpos, false ),
881 MessageTextFromValue( userYpos, false ),
882 MessageTextFromValue( hypot( userXpos, userYpos ), false ) );
883 SetStatusText( line, 3 );
884 }
885
887}
888
889
891{
892 EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
893
895}
896
897
899{
901
902 if( aCfg->m_Window.grid.sizes.empty() )
903 aCfg->m_Window.grid.sizes = aCfg->DefaultGridSizeList();
904
905 // Currently values read from config file are not used because the user cannot
906 // change this config
907 // if( aCfg->m_Window.zoom_factors.empty() )
908 {
910 }
911
912 // Some, but not all, derived classes have a PCBNEW_SETTINGS.
913 if( PCBNEW_SETTINGS* pcbnew_cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg ) )
914 m_polarCoords = pcbnew_cfg->m_PolarCoords;
915
916 wxASSERT( GetCanvas() );
917
918 if( GetCanvas() )
919 {
921
922 if( rs )
923 {
926 rs->SetDefaultFont( wxEmptyString ); // Always the KiCad font for PCBs
927 }
928 }
929}
930
931
933{
934 if( aErrorCode >= CLEANUP_FIRST )
935 return RPT_SEVERITY_ACTION;
936
938
939 return bds.m_DRCSeverities[ aErrorCode ];
940}
941
942
944{
946
947 // Some, but not all derived classes have a PCBNEW_SETTINGS.
948 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
949
950 if( cfg )
952}
953
954
956{
957 return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
958}
959
960
962{
963 return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
964}
965
966
968{
969 switch( GetFrameType() )
970 {
971 case FRAME_PCB_EDITOR:
975 default:
976 return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
977
981 case FRAME_CVPCB:
983 return Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
984 }
985}
986
987
989{
991}
992
993
994void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
995{
996 EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
997
999 PCB_RENDER_SETTINGS* renderSettings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings );
1000
1001 renderSettings->LoadColors( GetColorSettings( true ) );
1002 renderSettings->LoadDisplayOptions( GetDisplayOptions() );
1003
1004 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
1005 // they won't be found in the view layer's itemset for re-painting.
1007 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1008 {
1009 if( dynamic_cast<RATSNEST_VIEW_ITEM*>( aItem ) )
1010 {
1011 return KIGFX::ALL; // ratsnest display
1012 }
1013 else if( dynamic_cast<PCB_TRACK*>( aItem ) )
1014 {
1015 return KIGFX::REPAINT; // track, arc & via clearance display
1016 }
1017 else if( dynamic_cast<PAD*>( aItem ) )
1018 {
1019 return KIGFX::REPAINT; // pad clearance display
1020 }
1021
1022 return 0;
1023 } );
1024
1026
1028
1029 // The 3D viewer isn't in the Kiway, so send its update manually
1031
1032 if( viewer )
1033 viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1034}
1035
1036
1038{
1040
1042 m_autoSaveRequired = true;
1043
1045
1048}
1049
1050
1052{
1056}
1057
1058
1060{
1061 return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
1062}
1063
1064
1066{
1068
1069 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
1070 KIGFX::VIEW* view = canvas->GetView();
1071
1072 if( m_toolManager )
1073 {
1074 m_toolManager->SetEnvironment( m_pcb, view, canvas->GetViewControls(), config(), this );
1075
1077 }
1078
1079 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
1080 KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
1081 const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
1082
1083 settings->LoadDisplayOptions( displ_opts );
1084 settings->LoadColors( GetColorSettings() );
1085
1086 view->RecacheAllItems();
1088 canvas->StartDrawing();
1089
1090#if defined( KICAD_USE_3DCONNEXION )
1091 try
1092 {
1093 if( m_spaceMouse == nullptr )
1094 {
1096 }
1097 }
1098 catch( const std::system_error& e )
1099 {
1100 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
1101 }
1102#endif
1103}
1104
1105
1106void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh )
1107{
1111 m_displayOptions = aOptions;
1112
1113 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
1114 KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
1115
1116 view->UpdateDisplayOptions( aOptions );
1119
1120 // Vias on a restricted layer set must be redrawn when high contrast mode is changed
1121 if( hcChanged )
1122 {
1123 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
1124 // they won't be found in the view layer's itemset for re-painting.
1126 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1127 {
1128 if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( aItem ) )
1129 {
1130 if( via->GetViaType() == VIATYPE::BLIND_BURIED
1131 || via->GetViaType() == VIATYPE::MICROVIA
1132 || via->GetRemoveUnconnected() )
1133 {
1134 return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
1135 }
1136 }
1137 else if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
1138 {
1139 if( pad->GetRemoveUnconnected() )
1140 return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
1141 }
1142
1143 return 0;
1144 } );
1145 }
1146
1147 if( aRefresh )
1148 canvas->Refresh();
1149}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
BOX2< VECTOR2D > BOX2D
Definition: box2.h:848
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
WINDOW_SETTINGS m_Window
Definition: app_settings.h:187
const std::vector< wxString > DefaultGridSizeList() const
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:90
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:46
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
void SetGridOrigin(const VECTOR2I &aOrigin)
const VECTOR2I & GetGridOrigin()
const VECTOR2I & GetAuxOrigin()
void SetDefaultZoneSettings(const ZONE_SETTINGS &aSettings)
ZONE_SETTINGS & GetDefaultZoneSettings()
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: board.h:630
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:579
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:750
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:823
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:809
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:631
const PAGE_INFO & GetPageSettings() const
Definition: board.h:626
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:997
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:162
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:632
int GetCopperLayerCount() const
Definition: board.cpp:541
void IncrementTimeStamp()
Definition: board.cpp:226
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:627
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:629
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:682
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:634
void SetOrigin(const Vec &pos)
Definition: box2.h:202
const Vec & GetOrigin() const
Definition: box2.h:183
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
Vec Centre() const
Definition: box2.h:70
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
static DELETED_BOARD_ITEM * GetInstance()
Definition: board_item.h:368
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
void ReloadRequest()
Request reloading the 3D view.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification that common settings are updated.
FRAME_T GetFrameType() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void handleIconizeEvent(wxIconizeEvent &aEvent)
Handle a window iconize event.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
wxAuiManager m_auimgr
The base class for create windows for drawing purpose.
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
COLOR4D m_drawBgColor
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
virtual void UpdateMsgPanel()
Redraw the message panel.
void UpdateStatusBar() override
Update the status bar information.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
std::vector< wxWindow * > findDialogs()
bool m_showBorderAndTitleBlock
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
virtual void SetHighContrastLayer(int aLayer)
Take care of display settings for the given layer to be displayed in high contrast mode.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void StartDrawing()
Begin drawing if it was stopped previously.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsSelected() const
Definition: eda_item.h:106
virtual INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes)
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:91
void ClearBrightened()
Definition: eda_item.h:119
void SetBrightened()
Definition: eda_item.h:116
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
Definition: actions.h:210
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1670
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:1802
bool IsFlipped() const
Definition: footprint.h:324
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1586
VECTOR2I GetPosition() const override
Definition: footprint.h:188
KICAD_T Type() override
Definition: fp_lib_table.h:99
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:326
void SetIgnoreBlindBuriedVias(bool ignore)
Definition: collectors.h:471
void SetIgnoreTracks(bool ignore)
Definition: collectors.h:477
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:411
void SetIgnoreModulesOnFront(bool ignore)
Definition: collectors.h:435
void SetIgnoreModulesRefs(bool ignore)
Definition: collectors.h:465
void SetIgnoreMicroVias(bool ignore)
Definition: collectors.h:474
void SetIgnorePadsOnBack(bool ignore)
Definition: collectors.h:441
void SetIgnoreModulesOnBack(bool ignore)
Definition: collectors.h:429
void SetIgnoreModulesVals(bool ignore)
Definition: collectors.h:459
void SetIgnoreThroughVias(bool ignore)
Definition: collectors.h:468
void SetIgnoreThroughHolePads(bool ignore)
Definition: collectors.h:453
void SetIgnoreMTextsOnFront(bool ignore)
Definition: collectors.h:423
void SetIgnoreMTextsOnBack(bool ignore)
Definition: collectors.h:417
void SetIgnorePadsOnFront(bool ignore)
Definition: collectors.h:447
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
const VECTOR2D & GetGridSize() const
Return the grid size.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:158
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:163
PCB specific render settings.
Definition: pcb_painter.h:72
void LoadColors(const COLOR_SETTINGS *aSettings) override
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Load settings related to display options (high-contrast mode, full or outline modes for vias/pads/tra...
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
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:125
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDefaultFont(const wxString &aFont)
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
void SetHighlightFactor(float aFactor)
void SetSelectFactor(float aFactor)
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:511
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1591
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
Definition: view.cpp:1577
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:448
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1384
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1484
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
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:1494
Definition: kiid.h:48
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:274
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
The class that implements the public interface to the SpaceMouse plug-in.
void SetFocus(bool aFocus)
Set the connection to the 3Dconnexion driver to the focus state so that 3DMouse data is routed to thi...
A class to perform either relative or absolute display origin transforms for a single axis of a point...
Definition: pad.h:59
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
const wxSize GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:162
MAGNETIC_SETTINGS m_MagneticItems
SEVERITY GetSeverity(int aErrorCode) const override
virtual void OnDisplayOptionsChanged()
void FocusOnItems(std::vector< BOARD_ITEM * > aItems, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
ORIGIN_TRANSFORMS & GetOriginTransforms() override
Return a reference to the default ORIGIN_TRANSFORMS object.
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
virtual void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual void SwitchLayer(PCB_LAYER_ID aLayer)
Change the active layer in the frame.
virtual PCB_LAYER_ID GetActiveLayer() const
PCB_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
const VECTOR2I & GetAuxOrigin() const
virtual PCB_VIEWERS_SETTINGS_BASE * GetViewerSettingsBase() const
const VECTOR2I GetUserOrigin() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
void UpdateUserUnits(BOARD_ITEM *aItem, bool *aSelectedItemsModified=nullptr)
Update any references within aItem (or its descendants) to the user units.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
const VECTOR2I & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
const TITLE_BLOCK & GetTitleBlock() const override
const PAGE_INFO & GetPageSettings() const override
BOX2I GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
void SetDrawBgColor(const COLOR4D &aColor) override
virtual void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
NL_PCBNEW_PLUGIN * m_spaceMouse
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
const ZONE_SETTINGS & GetZoneSettings() const
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
virtual void doReCreateMenuBar() override
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
PCB_DISPLAY_OPTIONS m_displayOptions
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
void SetGridOrigin(const VECTOR2I &aPoint) 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...
PCB_ORIGIN_TRANSFORMS m_originTransforms
EDA_3D_VIEWER_FRAME * CreateAndShow3D_Frame()
Shows the 3D view frame.
EDA_3D_VIEWER_FRAME * Get3DViewerFrame()
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void DisplayGridMsg() override
Display the current grid pane on the status bar.
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
virtual void UpdateStatusBar() override
Update the status bar information.
Abstract dimension API.
Definition: pcb_dimension.h:96
void Update()
Update the dimension's cached text and geometry.
void SetUnits(EDA_UNITS aUnits)
DIM_UNITS_MODE GetUnitsMode() const
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
T ToDisplayRelY(T aInternalValue) const
T ToDisplayAbsX(T aInternalValue) const
T ToDisplayRelX(T aInternalValue) const
Transform a 2-D coordinate point referenced to the internal origin to the equivalent point referenced...
T ToDisplayAbsY(T aInternalValue) const
Parameters and options when plotting/printing a board.
A progress reporter interface for use in multi-threaded environments.
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:324
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
Definition: project.cpp:150
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
Definition: project.cpp:284
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:294
@ ELEM_FPTBL
Definition: project.h:206
Represent a set of closed polygons.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
@ CHAMFER_ACUTE_CORNERS
Acute angles are chamfered.
bool IsEmpty() const
void Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset union between a and b, store the result in it self For aFastMode meaning,...
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:172
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
@ GAL_SWITCH
Rendering engine changes.
Definition: tool_base.h:81
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
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).
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
EDA_UNITS GetUserUnits() const
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:70
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
SHAPE_POLY_SET * Outline()
Definition: zone.h:312
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the zone shape to a closed polygon Used in filling zones calculations Circles and arcs are ap...
Definition: zone.cpp:1320
@ CLEANUP_FIRST
Definition: cleanup_item.h:33
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
This file is part of the common library.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
#define _(s)
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
std::function< INSPECT_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Used to inspect and possibly collect the (search) results of iterating over a list or tree of KICAD_T...
Definition: eda_item.h:75
#define IS_NEW
New item, just created.
EDA_UNITS
Definition: eda_units.h:43
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
@ FRAME_CVPCB_DISPLAY
Definition: frame_type.h:49
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_WIZARD
Definition: frame_type.h:44
@ FRAME_FOOTPRINT_PREVIEW
Definition: frame_type.h:46
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
@ FRAME_PCB_DISPLAY3D
Definition: frame_type.h:45
@ FRAME_CVPCB
Definition: frame_type.h:48
@ ERROR_INSIDE
KIID niluuid(0)
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:825
@ LAYER_MOD_TEXT_INVISIBLE
text marked as invisible
Definition: layer_ids.h:200
@ LAYER_PAD_FR
smd pads, front layer
Definition: layer_ids.h:202
@ LAYER_MOD_TEXT
Definition: layer_ids.h:198
@ LAYER_TRACKS
Definition: layer_ids.h:212
@ LAYER_MOD_FR
show footprints on front
Definition: layer_ids.h:208
@ LAYER_PAD_BK
smd pads, back layer
Definition: layer_ids.h:203
@ LAYER_MOD_VALUES
show footprints values (when texts are visible)
Definition: layer_ids.h:210
@ LAYER_PADS_TH
multilayer pads, usually with holes
Definition: layer_ids.h:213
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:193
@ LAYER_MOD_BK
show footprints on back
Definition: layer_ids.h:209
@ LAYER_MOD_REFERENCES
show footprints references (when texts are visible)
Definition: layer_ids.h:211
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ F_Cu
Definition: layer_ids.h:64
Message panel definition file.
@ COLOR
Color has changed.
Definition: view_item.h:48
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:53
Declaration of the NL_PCBNEW_PLUGIN class.
wxDEFINE_EVENT(BOARD_CHANGED, wxCommandEvent)
@ BLIND_BURIED
@ PCB_ORIGIN_AUX
@ PCB_ORIGIN_GRID
@ PCB_ORIGIN_PAGE
see class PGM_BASE
SEVERITY
@ RPT_SEVERITY_ACTION
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
float highlight_factor
How much to brighten highlighted objects by.
Definition: app_settings.h:128
float select_factor
How much to brighten selected objects by.
Definition: app_settings.h:129
const double IU_PER_MILS
Definition: base_units.h:78
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
std::vector< wxString > sizes
Definition: app_settings.h:53
GRID_SETTINGS grid
Definition: app_settings.h:99
std::vector< double > zoom_factors
Definition: app_settings.h:96
double RAD2DEG(double rad)
Definition: trigo.h:196
@ FP_LIB_TABLE_T
Definition: typeinfo.h:235
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:110
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:104
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618
#define ZOOM_LIST_PCBNEW
Definition: zoom_defines.h:32