KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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 <3d_viewer/eda_3d_viewer_frame.h> // To include VIEWER3D_FRAMENAME
37#include <advanced_config.h>
38#include <base_units.h>
39#include <board.h>
40#include <cleanup_item.h>
41#include <collectors.h>
42#include <confirm.h>
43#include <footprint.h>
45#include <fp_lib_table.h>
46#include <kiface_base.h>
47#include <pcb_group.h>
48#include <pcb_painter.h>
49#include <pcbnew_id.h>
50#include <pcbnew_settings.h>
51#include <pcb_base_frame.h>
52#include <pcb_draw_panel_gal.h>
53#include <pgm_base.h>
55#include <zoom_defines.h>
56
57#include <math/vector2d.h>
58#include <math/vector2wx.h>
59#include <widgets/msgpanel.h>
60
63#include <tool/tool_manager.h>
65#include <tools/pcb_actions.h>
66#include <tool/grid_menu.h>
68
70
73
74wxDEFINE_EVENT( EDA_EVT_BOARD_CHANGED, wxCommandEvent );
75
76PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
77 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
78 long aStyle, const wxString& aFrameName ) :
79 EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName,
80 pcbIUScale ),
81 m_pcb( nullptr ),
82 m_originTransforms( *this ),
83 m_spaceMouse( nullptr )
84{
86}
87
88
90{
91 delete m_spaceMouse;
92 m_spaceMouse = nullptr;
93
94 // Ensure m_canvasType is up to date, to save it in config
96
97 delete m_pcb;
98 m_pcb = nullptr;
99}
100
101
102bool PCB_BASE_FRAME::canCloseWindow( wxCloseEvent& aEvent )
103{
104 // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
105 // board.
106 wxWindow* viewer3D = Get3DViewerFrame();
107
108 if( viewer3D )
109 viewer3D->Close( true );
110
111 // Similarly, wxConvBrokenFileNames uses some statically allocated variables that make it
112 // crash when run later from a d'tor.
113 Prj().Cleanup3DCache();
114
115 return true;
116}
117
118
119void PCB_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
120{
122
123 if( m_spaceMouse != nullptr && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
124 m_spaceMouse->SetFocus( aEvent.GetActive() );
125}
126
127
128void PCB_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
129{
131
132 if( m_spaceMouse != nullptr && aEvent.IsIconized()
134 m_spaceMouse->SetFocus( false );
135}
136
137
139{
140 wxWindow* frame = FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) );
141 return dynamic_cast<EDA_3D_VIEWER_FRAME*>( frame );
142}
143
144
145void PCB_BASE_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
146{
147 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
148
149 if( draw3DFrame )
150 {
151 if( aTitle )
152 draw3DFrame->SetTitle( *aTitle );
153
154 if( aMarkDirty )
155 draw3DFrame->ReloadRequest();
156
157 if( aRefresh )
158 draw3DFrame->Redraw();
159 }
160}
161
162
164{
165 // This is a lazy loading function, it loads the project specific table when
166 // that table is asked for, not before.
167
169
170 // its gotta be NULL or a FP_LIB_TABLE, or a bug.
171 wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
172
173 if( !tbl )
174 {
175 // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
176 // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
177 // stack this way, all using the same global fallback table.
178 tbl = new FP_LIB_TABLE( &GFootprintTable );
179
180 SetElem( ELEM_FPTBL, tbl );
181
182 wxString projectFpLibTableFileName = FootprintLibTblName();
183
184 try
185 {
186 tbl->Load( projectFpLibTableFileName );
187 }
188 catch( const IO_ERROR& ioe )
189 {
190 DisplayErrorMessage( nullptr, _( "Error loading project footprint libraries." ),
191 ioe.What() );
192 }
193 catch( ... )
194 {
195 DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ) );
196 }
197 }
198
199 return tbl;
200}
201
202
204{
205 if( m_pcb != aBoard )
206 {
207 delete m_pcb;
208 m_pcb = aBoard;
209
210 if( GetBoard() )
212
213 if( GetBoard() && GetCanvas() )
214 {
216
217 if( rs )
218 {
219 rs->SetDashLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineDashRatio() );
220 rs->SetGapLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineGapRatio() );
221 }
222 }
223
224 wxCommandEvent e( EDA_EVT_BOARD_CHANGED );
225 ProcessEventLocally( e );
226
227 for( wxEvtHandler* listener : m_boardChangeListeners )
228 {
229 wxCHECK2( listener, continue );
230
231 // Use the windows variant when handling event messages in case there is any special
232 // event handler pre and/or post processing specific to windows.
233 wxWindow* win = dynamic_cast<wxWindow*>( listener );
234
235 if( win )
236 win->HandleWindowEvent( e );
237 else
238 listener->SafelyProcessEvent( e );
239 }
240 }
241}
242
243
244void PCB_BASE_FRAME::AddBoardChangeListener( wxEvtHandler* aListener )
245{
246 auto it = std::find( m_boardChangeListeners.begin(), m_boardChangeListeners.end(), aListener );
247
248 // Don't add duplicate listeners.
249 if( it == m_boardChangeListeners.end() )
250 m_boardChangeListeners.push_back( aListener );
251}
252
253
254void PCB_BASE_FRAME::RemoveBoardChangeListener( wxEvtHandler* aListener )
255{
256 auto it = std::find( m_boardChangeListeners.begin(), m_boardChangeListeners.end(), aListener );
257
258 // Don't add duplicate listeners.
259 if( it != m_boardChangeListeners.end() )
260 m_boardChangeListeners.erase( it );
261}
262
263
265{
266 if( aFootprint )
267 {
268 GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
269
270 aFootprint->SetFlags( IS_NEW );
271 aFootprint->SetPosition( VECTOR2I( 0, 0 ) ); // cursor in GAL may not be initialized yet
272
273 // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
274 // built from a board)
275 if( aFootprint->IsFlipped() )
276 aFootprint->Flip( aFootprint->GetPosition(), GetPcbNewSettings()->m_FlipLeftRight );
277
278 // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
279 // it might be stored in another orientation if the lib is an archive built from a board)
280 aFootprint->SetOrientation( ANGLE_0 );
281
282 GetBoard()->UpdateUserUnits( aFootprint, GetCanvas()->GetView() );
283 }
284}
285
286
288{
289 return GetBoard()->GetItem( aId );
290}
291
292
294{
295 std::vector<BOARD_ITEM*> items;
296
297 if( aItem )
298 items.push_back( aItem );
299
300 FocusOnItems( items, aLayer );
301}
302
303
304void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID aLayer )
305{
306 static std::vector<KIID> lastBrightenedItemIDs;
307
308 BOARD_ITEM* lastItem = nullptr;
309
310 for( KIID lastBrightenedItemID : lastBrightenedItemIDs )
311 {
314 #if BOOST_VERSION >= 106700
315 try
316 {
317 lastItem = GetBoard()->GetItem( lastBrightenedItemID );
318 }
319 catch( const boost::uuids::entropy_error& )
320 {
321 wxLogError( wxT( "A Boost UUID entropy exception was thrown in %s:%s." ),
322 __FILE__, __FUNCTION__ );
323 }
324 #else
325 lastItem = GetBoard()->GetItem( lastBrightenedItemID );
326 #endif
327
328 if( lastItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
329 {
330 lastItem->ClearBrightened();
331
332 if( lastItem->Type() == PCB_FOOTPRINT_T )
333 {
334 static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
335 [&]( BOARD_ITEM* child )
336 {
337 child->ClearBrightened();
338 } );
339 }
340 else if( lastItem->Type() == PCB_GROUP_T )
341 {
342 static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
343 [&]( BOARD_ITEM* child )
344 {
345 child->ClearBrightened();
346 } );
347 }
348
349 GetCanvas()->GetView()->Update( lastItem );
350 lastBrightenedItemID = niluuid;
351 GetCanvas()->Refresh();
352 }
353 }
354
355 lastBrightenedItemIDs.clear();
356
357 if( aItems.empty() )
358 return;
359
360 VECTOR2I focusPt;
361 KIGFX::VIEW* view = GetCanvas()->GetView();
362 SHAPE_POLY_SET viewportPoly( view->GetViewport() );
363
364 for( wxWindow* dialog : findDialogs() )
365 {
366 wxPoint dialogPos = GetCanvas()->ScreenToClient( dialog->GetScreenPosition() );
367 SHAPE_POLY_SET dialogPoly( BOX2D( view->ToWorld( ToVECTOR2D( dialogPos ), true ),
368 view->ToWorld( ToVECTOR2D( dialog->GetSize() ), false ) ) );
369
370 try
371 {
372 viewportPoly.BooleanSubtract( dialogPoly, SHAPE_POLY_SET::PM_FAST );
373 }
374 catch( const ClipperLib::clipperException& exc )
375 {
376 // This may be overkill and could be an assertion but we are more likely to
377 // find any clipper errors this way.
378 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
379 }
380 }
381
382 SHAPE_POLY_SET itemPoly, clippedPoly;
383
384 for( BOARD_ITEM* item : aItems )
385 {
386 if( item && item != DELETED_BOARD_ITEM::GetInstance() )
387 {
388 item->SetBrightened();
389
390 if( item->Type() == PCB_FOOTPRINT_T )
391 {
392 static_cast<FOOTPRINT*>( item )->RunOnChildren(
393 [&]( BOARD_ITEM* child )
394 {
395 child->SetBrightened();
396 });
397 }
398 else if( item->Type() == PCB_GROUP_T )
399 {
400 static_cast<PCB_GROUP*>( item )->RunOnChildren(
401 [&]( BOARD_ITEM* child )
402 {
403 child->SetBrightened();
404 });
405 }
406
407 GetCanvas()->GetView()->Update( item );
408 lastBrightenedItemIDs.push_back( item->m_Uuid );
409
410 // Focus on the object's location. Prefer a visible part of the object to its anchor
411 // in order to keep from scrolling around.
412
413 focusPt = item->GetPosition();
414
415 if( aLayer == UNDEFINED_LAYER )
416 aLayer = item->GetLayerSet().Seq()[0];
417
418 switch( item->Type() )
419 {
420 case PCB_FOOTPRINT_T:
421 try
422 {
423 itemPoly = static_cast<FOOTPRINT*>( item )->GetBoundingHull();
424 }
425 catch( const ClipperLib::clipperException& exc )
426 {
427 // This may be overkill and could be an assertion but we are more likely to
428 // find any clipper errors this way.
429 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
430 }
431
432 break;
433
434 case PCB_PAD_T:
435 case PCB_MARKER_T:
436 case PCB_VIA_T:
437 FocusOnLocation( item->GetFocusPosition() );
438 GetCanvas()->Refresh();
439 return;
440
441 case PCB_SHAPE_T:
442 case PCB_TEXT_T:
443 case PCB_TEXTBOX_T:
444 case PCB_TRACE_T:
445 case PCB_ARC_T:
447 case PCB_DIM_LEADER_T:
448 case PCB_DIM_CENTER_T:
449 case PCB_DIM_RADIAL_T:
451 item->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ),
452 ERROR_INSIDE );
453 break;
454
455 case PCB_ZONE_T:
456 {
457 ZONE* zone = static_cast<ZONE*>( item );
458 #if 0
459 // Using the filled area shapes to find a Focus point can give good results, but
460 // unfortunately the calculations are highly time consuming, even for not very
461 // large areas (can be easily a few minutes for large areas).
462 // so we used only the zone outline that usually do not have too many vertices.
463 zone->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ),
464 ERROR_INSIDE );
465
466 if( itemPoly.IsEmpty() )
467 itemPoly = *zone->Outline();
468 #else
469 // much faster calculation time when using only the zone outlines
470 itemPoly = *zone->Outline();
471 #endif
472
473 break;
474 }
475
476 default:
477 {
478 BOX2I item_bbox = item->GetBoundingBox();
479 itemPoly.NewOutline();
480 itemPoly.Append( item_bbox.GetOrigin() );
481 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(), 0 ) );
482 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( 0, item_bbox.GetHeight() ) );
483 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(),
484 item_bbox.GetHeight() ) );
485 break;
486 }
487 }
488
489 try
490 {
491 clippedPoly.BooleanIntersection( itemPoly, viewportPoly, SHAPE_POLY_SET::PM_FAST );
492 }
493 catch( const ClipperLib::clipperException& exc )
494 {
495 // This may be overkill and could be an assertion but we are more likely to
496 // find any clipper errors this way.
497 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
498 }
499
500 if( !clippedPoly.IsEmpty() )
501 itemPoly = clippedPoly;
502 }
503 }
504
505 /*
506 * Perform a step-wise deflate to find the visual-center-of-mass
507 */
508
509 BOX2I bbox = itemPoly.BBox();
510 int step = std::min( bbox.GetWidth(), bbox.GetHeight() ) / 10;
511
512 while( !itemPoly.IsEmpty() )
513 {
514 focusPt = itemPoly.BBox().Centre();
515
516 try
517 {
519 }
520 catch( const ClipperLib::clipperException& exc )
521 {
522 // This may be overkill and could be an assertion but we are more likely to
523 // find any clipper errors this way.
524 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
525 }
526 }
527
528 FocusOnLocation( focusPt );
529
530 GetCanvas()->Refresh();
531}
532
533
535{
536 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
537
538 if( view && GetBoard()->m_SolderMask && view->HasItem( GetBoard()->m_SolderMask ) )
539 view->Remove( GetBoard()->m_SolderMask );
540}
541
542
544{
545 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
546
547 if( view && GetBoard()->m_SolderMask )
548 {
549 if( view->HasItem( GetBoard()->m_SolderMask ) )
550 view->Remove( GetBoard()->m_SolderMask );
551
552 view->Add( GetBoard()->m_SolderMask );
553 }
554}
555
556
557void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
558{
559 m_pcb->SetPageSettings( aPageSettings );
560
561 if( GetScreen() )
563}
564
565
567{
568 return m_pcb->GetPageSettings();
569}
570
571
573{
574 // this function is only needed because EDA_DRAW_FRAME is not compiled
575 // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
576 // into an application specific source file.
578}
579
580
582{
584}
585
586
588{
590}
591
592
594{
596}
597
598
600{
601 VECTOR2I origin( 0, 0 );
602
603 switch( GetPcbNewSettings()->m_Display.m_DisplayOrigin )
604 {
605 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE: break;
606 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
607 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID: origin = GetGridOrigin(); break;
608 default: wxASSERT( false ); break;
609 }
610
611 return origin;
612}
613
615{
616 return m_originTransforms;
617}
618
619
621{
622 return m_pcb->GetTitleBlock();
623}
624
625
627{
628 m_pcb->SetTitleBlock( aTitleBlock );
629}
630
631
633{
634 return m_pcb->GetDesignSettings();
635}
636
637
639{
640 m_drawBgColor= aColor;
641 m_auimgr.Update();
642}
643
644
646{
648}
649
650
652{
654}
655
656
658{
659 return m_pcb->GetPlotOptions();
660}
661
662
664{
665 m_pcb->SetPlotOptions( aSettings );
666}
667
668
669BOX2I PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
670{
671 BOX2I area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
672
673 if( area.GetWidth() == 0 && area.GetHeight() == 0 )
674 {
675 VECTOR2I pageSize = GetPageSizeIU();
676
678 {
679 area.SetOrigin( 0, 0 );
680 area.SetEnd( pageSize.x, pageSize.y );
681 }
682 else
683 {
684 area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
685 area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
686 }
687 }
688
689 return area;
690}
691
692
693// Virtual function
695{
696}
697
698
700{
701 // call my base class
703
704 // tooltips in toolbars
706}
707
708
710{
711 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
712
713 if( !draw3DFrame )
714 draw3DFrame = new EDA_3D_VIEWER_FRAME( &Kiway(), this, _( "3D Viewer" ) );
715
716 // Raising the window does not show the window on Windows if iconized. This should work
717 // on any platform.
718 if( draw3DFrame->IsIconized() )
719 draw3DFrame->Iconize( false );
720
721 draw3DFrame->Raise();
722 draw3DFrame->Show( true );
723
724 // Raising the window does not set the focus on Linux. This should work on any platform.
725 if( wxWindow::FindFocus() != draw3DFrame )
726 draw3DFrame->SetFocus();
727
728 // Allocate a slice of time to display the 3D frame
729 // a call to wxSafeYield() should be enough (and better), but on Linux we need
730 // to call wxYield()
731 // otherwise the activity messages are not displayed during the first board loading
732 wxYield();
733
734 // Note, the caller is responsible to load/update the board 3D view.
735 // after frame creation the board is not automatically created.
736
737 return draw3DFrame;
738}
739
740
742{
743 PCB_LAYER_ID preslayer = GetActiveLayer();
744 auto& displ_opts = GetDisplayOptions();
745
746 // Check if the specified layer matches the present layer
747 if( layer == preslayer )
748 return;
749
750 // Copper layers cannot be selected unconditionally; how many of those layers are
751 // currently enabled needs to be checked.
752 if( IsCopperLayer( layer ) )
753 {
754 // If only one copper layer is enabled, the only such layer that can be selected to
755 // is the "Copper" layer (so the selection of any other copper layer is disregarded).
756 if( m_pcb->GetCopperLayerCount() < 2 )
757 {
758 if( layer != B_Cu )
759 return;
760 }
761
762 // If more than one copper layer is enabled, the "Copper" and "Component" layers
763 // can be selected, but the total number of copper layers determines which internal
764 // layers are also capable of being selected.
765 else
766 {
767 if( layer != B_Cu && layer != F_Cu && layer >= ( m_pcb->GetCopperLayerCount() - 1 ) )
768 return;
769 }
770 }
771
772 // Is yet more checking required? E.g. when the layer to be selected is a non-copper
773 // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
774 // ...
775
776 SetActiveLayer( layer );
777
778 if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
779 GetCanvas()->Refresh();
780}
781
782
784{
786 GetCanvas()->GetView() );
787
788 // account for the globals
803
804 return guide;
805}
806
807
809{
810 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
811 wxString line;
812
813 line.Printf( wxT( "grid X %s Y %s" ),
814 MessageTextFromValue( gridSize.x, false ),
815 MessageTextFromValue( gridSize.y, false ) );
816
817 SetStatusText( line, 4 );
818}
819
820
822{
824
825 BASE_SCREEN* screen = GetScreen();
826
827 if( !screen )
828 return;
829
830 wxString line;
832
833 if( GetShowPolarCoords() ) // display polar coordinates
834 {
835 double dx = cursorPos.x - screen->m_LocalOrigin.x;
836 double dy = cursorPos.y - screen->m_LocalOrigin.y;
837 double theta = RAD2DEG( atan2( -dy, dx ) );
838 double ro = hypot( dx, dy );
839
840 line.Printf( wxT( "r %s theta %.3f" ),
841 MessageTextFromValue( ro, false ),
842 theta );
843
844 SetStatusText( line, 3 );
845 }
846
847 // Transform absolute coordinates for user origin preferences
848 double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
849 double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
850
851 // Display absolute coordinates:
852 line.Printf( wxT( "X %s Y %s" ),
853 MessageTextFromValue( userXpos, false ),
854 MessageTextFromValue( userYpos, false ) );
855 SetStatusText( line, 2 );
856
857 if( !GetShowPolarCoords() ) // display relative cartesian coordinates
858 {
859 // Calculate relative coordinates
860 double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
861 double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
862
863 // Transform relative coordinates for user origin preferences
864 userXpos = m_originTransforms.ToDisplayRelX( relXpos );
865 userYpos = m_originTransforms.ToDisplayRelY( relYpos );
866
867 line.Printf( wxT( "dx %s dy %s dist %s" ),
868 MessageTextFromValue( userXpos, false ),
869 MessageTextFromValue( userYpos, false ),
870 MessageTextFromValue( hypot( userXpos, userYpos ), false ) );
871 SetStatusText( line, 3 );
872 }
873
875}
876
877
879{
880 EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
881
882 if( GetBoard() )
884
886}
887
888
890{
892
893 if( aCfg->m_Window.grid.sizes.empty() )
894 aCfg->m_Window.grid.sizes = aCfg->DefaultGridSizeList();
895
896 // Currently values read from config file are not used because the user cannot
897 // change this config
898 // if( aCfg->m_Window.zoom_factors.empty() )
899 {
901 }
902
903 // Some, but not all, derived classes have a PCBNEW_SETTINGS.
904 if( PCBNEW_SETTINGS* pcbnew_cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg ) )
905 m_polarCoords = pcbnew_cfg->m_PolarCoords;
906
907 wxASSERT( GetCanvas() );
908
909 if( GetCanvas() )
910 {
912
913 if( rs )
914 {
917 rs->SetDefaultFont( wxEmptyString ); // Always the KiCad font for PCBs
918 }
919 }
920}
921
922
924{
925 if( aErrorCode >= CLEANUP_FIRST )
926 return RPT_SEVERITY_ACTION;
927
929
930 return bds.m_DRCSeverities[ aErrorCode ];
931}
932
933
935{
937
938 // Some, but not all derived classes have a PCBNEW_SETTINGS.
939 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
940
941 if( cfg )
943}
944
945
947{
948 return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
949}
950
951
953{
954 return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
955}
956
957
959{
960 switch( GetFrameType() )
961 {
962 case FRAME_PCB_EDITOR:
966 default:
967 return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
968
972 case FRAME_CVPCB:
974 return Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
975 }
976}
977
978
980{
982}
983
984
985void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
986{
987 EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
988
990 PCB_RENDER_SETTINGS* renderSettings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings );
991
992 renderSettings->LoadColors( GetColorSettings( true ) );
993 renderSettings->LoadDisplayOptions( GetDisplayOptions() );
994
995 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
996 // they won't be found in the view layer's itemset for re-painting.
998 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
999 {
1000 if( dynamic_cast<RATSNEST_VIEW_ITEM*>( aItem ) )
1001 {
1002 return KIGFX::ALL; // ratsnest display
1003 }
1004 else if( dynamic_cast<PCB_TRACK*>( aItem ) )
1005 {
1006 return KIGFX::REPAINT; // track, arc & via clearance display
1007 }
1008 else if( dynamic_cast<PAD*>( aItem ) )
1009 {
1010 return KIGFX::REPAINT; // pad clearance display
1011 }
1012
1013 return 0;
1014 } );
1015
1017
1019
1020 // The 3D viewer isn't in the Kiway, so send its update manually
1022
1023 if( viewer )
1024 viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1025}
1026
1027
1029{
1031
1033 m_autoSaveRequired = true;
1034
1036
1039}
1040
1041
1043{
1047}
1048
1049
1051{
1052 return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
1053}
1054
1055
1057{
1059
1060 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
1061 KIGFX::VIEW* view = canvas->GetView();
1062
1063 if( m_toolManager )
1064 {
1065 m_toolManager->SetEnvironment( m_pcb, view, canvas->GetViewControls(), config(), this );
1066
1068 }
1069
1070 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
1071 KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
1072 const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
1073
1074 settings->LoadDisplayOptions( displ_opts );
1075 settings->LoadColors( GetColorSettings() );
1076
1077 view->RecacheAllItems();
1079 canvas->StartDrawing();
1080
1081 if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
1082 {
1083 try
1084
1085 {
1086 if( m_spaceMouse == nullptr )
1087 {
1089 }
1090 }
1091 catch( const std::system_error& e )
1092 {
1093 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
1094 }
1095 }
1096}
1097
1098
1099void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh )
1100{
1102 bool hcVisChanged = m_displayOptions.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN
1103 || aOptions.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN;
1104 m_displayOptions = aOptions;
1105
1106 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
1107 KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
1108
1109 view->UpdateDisplayOptions( aOptions );
1112
1113 // Vias on a restricted layer set must be redrawn when high contrast mode is changed
1114 if( hcChanged )
1115 {
1116 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
1117 // they won't be found in the view layer's itemset for re-painting.
1119 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1120 {
1121 if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( aItem ) )
1122 {
1123 if( via->GetViaType() == VIATYPE::BLIND_BURIED
1124 || via->GetViaType() == VIATYPE::MICROVIA
1125 || via->GetRemoveUnconnected() )
1126 {
1127 return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
1128 }
1129 }
1130 else if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
1131 {
1132 if( pad->GetRemoveUnconnected() )
1133 return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
1134 }
1135
1136 return 0;
1137 } );
1138 }
1139
1140 if( aRefresh )
1141 canvas->Refresh();
1142}
1143
1144
1146{
1147 Unbind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
1148
1149 if( !aFootprint )
1150 {
1151 m_watcher.reset();
1152 return;
1153 }
1154
1155 wxString libfullname;
1157
1158 if( !aFootprint || !tbl )
1159 return;
1160
1161 try
1162 {
1163 const FP_LIB_TABLE_ROW* row = tbl->FindRow( aFootprint->GetFPID().GetLibNickname() );
1164
1165 if( !row )
1166 return;
1167
1168 libfullname = row->GetFullURI( true );
1169 }
1170 catch( const std::exception& e )
1171 {
1172 DisplayInfoMessage( this, e.what() );
1173 return;
1174 }
1175 catch( const IO_ERROR& error )
1176 {
1177 wxLogTrace( "KICAD_LIB_WATCH", "Error: %s", error.What() );
1178 return;
1179 }
1180
1181 m_watcherFileName.Assign( libfullname, aFootprint->GetFPID().GetLibItemName(),
1183
1184 if( !m_watcherFileName.FileExists() )
1185 return;
1186
1187 m_watcherLastModified = m_watcherFileName.GetModificationTime();
1188
1189 Bind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
1190 m_watcher = std::make_unique<wxFileSystemWatcher>();
1191 m_watcher->SetOwner( this );
1192
1193 wxFileName fn;
1194 fn.AssignDir( m_watcherFileName.GetPath() );
1195 fn.DontFollowLink();
1196
1197 m_watcher->AddTree( fn );
1198}
1199
1200
1201void PCB_BASE_FRAME::OnFPChange( wxFileSystemWatcherEvent& aEvent )
1202{
1203 if( aEvent.GetPath() != m_watcherFileName.GetFullPath() )
1204 return;
1205
1206 // Start the debounce timer (set to 1 second)
1207 if( !m_watcherDebounceTimer.StartOnce( 1000 ) )
1208 {
1209 wxLogTrace( "KICAD_LIB_WATCH", "Failed to start the debounce timer" );
1210 return;
1211 }
1212}
1213
1214
1216{
1217 wxLogTrace( "KICAD_LIB_WATCH", "OnFpChangeDebounceTimer" );
1218
1219 // Disable logging to avoid spurious messages and check if the file has changed
1220 wxLog::EnableLogging( false );
1221 wxDateTime lastModified = m_watcherFileName.GetModificationTime();
1222 wxLog::EnableLogging( true );
1223
1224 if( lastModified == m_watcherLastModified || !lastModified.IsValid() )
1225 return;
1226
1227 m_watcherLastModified = lastModified;
1228
1231
1232 if( !fp || !tbl )
1233 return;
1234
1236 || IsOK( this, _( "The library containing the current footprint has changed.\n"
1237 "Do you want to reload the footprint?" ) ) )
1238 {
1239 wxString fpname = fp->GetFPID().GetLibItemName();
1240 wxString nickname = fp->GetFPID().GetLibNickname();
1241
1242 try
1243 {
1244 FOOTPRINT* newfp = tbl->FootprintLoad( nickname, fpname );
1245
1246 if( newfp )
1247 ReloadFootprint( newfp );
1248 }
1249 catch( const IO_ERROR& ioe )
1250 {
1251 DisplayError( this, ioe.What() );
1252 }
1253 }
1254}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
constexpr int ARC_LOW_DEF
Definition: base_units.h:120
BOX2< VECTOR2D > BOX2D
Definition: box2.h:848
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
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 SetContentModified(bool aModified=true)
Definition: base_screen.h:59
void InitDataPoints(const VECTOR2I &aPageSizeInternalUnits)
Definition: base_screen.cpp:46
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:71
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:270
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: board.h:642
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:625
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:796
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:858
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:844
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:677
const PAGE_INFO & GetPageSettings() const
Definition: board.h:638
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition: board.cpp:1002
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:1069
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:168
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:405
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:644
int GetCopperLayerCount() const
Definition: board.cpp:587
void IncrementTimeStamp()
Definition: board.cpp:237
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:639
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:641
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:728
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:646
void SetUserUnits(EDA_UNITS aUnits)
Definition: board.h:651
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:384
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
virtual bool IsContentModified() const
Get if the contents of the frame have been modified since the last save.
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
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:123
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
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:211
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1656
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:1728
bool IsFlipped() const
Definition: footprint.h:326
const LIB_ID & GetFPID() const
Definition: footprint.h:214
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1596
VECTOR2I GetPosition() const override
Definition: footprint.h:190
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:41
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
KICAD_T Type() override
Definition: fp_lib_table.h:99
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
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:103
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:156
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:161
PCB specific render settings.
Definition: pcb_painter.h:70
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:508
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
Definition: view.cpp:1594
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:445
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1401
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1501
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:1511
Definition: kiid.h:48
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
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 VECTOR2I 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
std::unique_ptr< wxFileSystemWatcher > m_watcher
virtual void ReloadFootprint(FOOTPRINT *aFootprint)
Reload the footprint from the library.
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.
wxDateTime m_watcherLastModified
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 RemoveBoardChangeListener(wxEvtHandler *aListener)
Remove aListener to from the board changed listener list.
void handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
void setFPWatcher(FOOTPRINT *aFootprint)
Creates (or removes) a watcher on the specified footprint.
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.
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
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()
std::vector< wxEvtHandler * > m_boardChangeListeners
void OnFPChange(wxFileSystemWatcherEvent &aEvent)
Handler for FP change events.
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
void OnFpChangeDebounceTimer(wxTimerEvent &aEvent)
Handler for the filesystem watcher debounce timer.
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.
void AddBoardChangeListener(wxEvtHandler *aListener)
Add aListener to post #EDA_EVT_BOARD_CHANGED command events to.
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
PCB_ORIGIN_TRANSFORMS m_originTransforms
EDA_3D_VIEWER_FRAME * CreateAndShow3D_Frame()
Shows the 3D view frame.
wxTimer m_watcherDebounceTimer
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.
wxFileName m_watcherFileName
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.
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 difference For aFastMode meaning, see function booleanOp.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
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:82
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:72
SHAPE_POLY_SET * Outline()
Definition: zone.h:325
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:1315
@ CLEANUP_FIRST
Definition: cleanup_item.h:33
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:363
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:283
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:335
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:308
This file is part of the common library.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
#define _(s)
Declaration of the eda_3d_viewer class.
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:429
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
#define IS_NEW
New item, just created.
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
bool m_Use3DConnexionDriver
Use the 3DConnexion Driver.
const std::string KiCadFootprintFileExtension
KIID niluuid(0)
KIWAY Kiway
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:831
@ 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(EDA_EVT_BOARD_CHANGED, wxCommandEvent)
Class to handle a set of BOARD_ITEMs.
see class PGM_BASE
SEVERITY
@ RPT_SEVERITY_ACTION
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
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:225
@ 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:101
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:98
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:93
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:99
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:106
@ 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:103
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:95
@ 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:97
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:94
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:92
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:100
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)
Definition: vector2wx.h:40
Definition of file extensions used in Kicad.
#define ZOOM_LIST_PCBNEW
Definition: zoom_defines.h:32