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_painter.h>
48#include <pcbnew_id.h>
49#include <pcbnew_settings.h>
50#include <pcb_base_frame.h>
51#include <pcb_draw_panel_gal.h>
52#include <pgm_base.h>
53#include <project_pcb.h>
55#include <zoom_defines.h>
56
57#include <math/vector2d.h>
58#include <math/vector2wx.h>
59#include <widgets/msgpanel.h>
60#include <wx/fswatcher.h>
61
64#include <tool/tool_manager.h>
66#include <tools/pcb_actions.h>
67#include <tool/grid_menu.h>
69
71
74
75wxDEFINE_EVENT( EDA_EVT_BOARD_CHANGED, wxCommandEvent );
76
77PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
78 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
79 long aStyle, const wxString& aFrameName ) :
80 EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName,
81 pcbIUScale ),
82 m_pcb( nullptr ),
83 m_originTransforms( *this ),
84 m_spaceMouse( nullptr )
85{
87}
88
89
91{
92 delete m_spaceMouse;
93 m_spaceMouse = nullptr;
94
95 // Ensure m_canvasType is up to date, to save it in config
96 if( GetCanvas() )
98
99 delete m_pcb;
100 m_pcb = nullptr;
101}
102
103
104bool PCB_BASE_FRAME::canCloseWindow( wxCloseEvent& aEvent )
105{
106 // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
107 // board.
108 wxWindow* viewer3D = Get3DViewerFrame();
109
110 if( viewer3D )
111 viewer3D->Close( true );
112
113 // Similarly, wxConvBrokenFileNames uses some statically allocated variables that make it
114 // crash when run later from a d'tor.
116
117 return true;
118}
119
120
121void PCB_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
122{
124
125 if( m_spaceMouse )
126 m_spaceMouse->SetFocus( aEvent.GetActive() );
127}
128
129
130void PCB_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
131{
133
134 if( m_spaceMouse != nullptr && aEvent.IsIconized() )
135 m_spaceMouse->SetFocus( false );
136}
137
138
140{
141 wxWindow* frame = FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) );
142 return dynamic_cast<EDA_3D_VIEWER_FRAME*>( frame );
143}
144
145
146void PCB_BASE_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
147{
148 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
149
150 if( draw3DFrame )
151 {
152 if( aTitle )
153 draw3DFrame->SetTitle( *aTitle );
154
155 if( aMarkDirty )
156 draw3DFrame->ReloadRequest();
157
158 if( aRefresh )
159 draw3DFrame->Redraw();
160 }
161}
162
163
165{
166 if( m_pcb != aBoard )
167 {
168 delete m_pcb;
169 m_pcb = aBoard;
170
171 if( GetBoard() )
173
174 if( GetBoard() && GetCanvas() )
175 {
177
178 if( rs )
179 {
180 rs->SetDashLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineDashRatio() );
181 rs->SetGapLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineGapRatio() );
182 }
183 }
184
185 wxCommandEvent e( EDA_EVT_BOARD_CHANGED );
186 ProcessEventLocally( e );
187
188 for( wxEvtHandler* listener : m_boardChangeListeners )
189 {
190 wxCHECK2( listener, continue );
191
192 // Use the windows variant when handling event messages in case there is any special
193 // event handler pre and/or post processing specific to windows.
194 wxWindow* win = dynamic_cast<wxWindow*>( listener );
195
196 if( win )
197 win->HandleWindowEvent( e );
198 else
199 listener->SafelyProcessEvent( e );
200 }
201 }
202}
203
204
205void PCB_BASE_FRAME::AddBoardChangeListener( wxEvtHandler* aListener )
206{
207 auto it = std::find( m_boardChangeListeners.begin(), m_boardChangeListeners.end(), aListener );
208
209 // Don't add duplicate listeners.
210 if( it == m_boardChangeListeners.end() )
211 m_boardChangeListeners.push_back( aListener );
212}
213
214
215void PCB_BASE_FRAME::RemoveBoardChangeListener( wxEvtHandler* aListener )
216{
217 auto it = std::find( m_boardChangeListeners.begin(), m_boardChangeListeners.end(), aListener );
218
219 // Don't add duplicate listeners.
220 if( it != m_boardChangeListeners.end() )
221 m_boardChangeListeners.erase( it );
222}
223
224
226{
227 if( aFootprint )
228 {
229 GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
230
231 aFootprint->SetFlags( IS_NEW );
232 aFootprint->SetPosition( VECTOR2I( 0, 0 ) ); // cursor in GAL may not be initialized yet
233
234 // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
235 // built from a board)
236 if( aFootprint->IsFlipped() )
237 aFootprint->Flip( aFootprint->GetPosition(), GetPcbNewSettings()->m_FlipLeftRight );
238
239 // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
240 // it might be stored in another orientation if the lib is an archive built from a board)
241 aFootprint->SetOrientation( ANGLE_0 );
242
243 GetBoard()->UpdateUserUnits( aFootprint, GetCanvas()->GetView() );
244 }
245}
246
247
249{
250 return GetBoard()->GetItem( aId );
251}
252
253
255{
256 std::vector<BOARD_ITEM*> items;
257
258 if( aItem )
259 items.push_back( aItem );
260
261 FocusOnItems( items, aLayer );
262}
263
264
265void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID aLayer )
266{
267 static std::vector<KIID> lastBrightenedItemIDs;
268
269 BOARD_ITEM* lastItem = nullptr;
270
271 for( KIID lastBrightenedItemID : lastBrightenedItemIDs )
272 {
275 #if BOOST_VERSION >= 106700
276 try
277 {
278 lastItem = GetBoard()->GetItem( lastBrightenedItemID );
279 }
280 catch( const boost::uuids::entropy_error& )
281 {
282 wxLogError( wxT( "A Boost UUID entropy exception was thrown in %s:%s." ),
283 __FILE__, __FUNCTION__ );
284 }
285 #else
286 lastItem = GetBoard()->GetItem( lastBrightenedItemID );
287 #endif
288
289 if( lastItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
290 {
291 lastItem->ClearBrightened();
292
293 lastItem->RunOnDescendants(
294 [&]( BOARD_ITEM* child )
295 {
296 child->ClearBrightened();
297 } );
298
299 GetCanvas()->GetView()->Update( lastItem );
300 lastBrightenedItemID = niluuid;
301 GetCanvas()->Refresh();
302 }
303 }
304
305 lastBrightenedItemIDs.clear();
306
307 if( aItems.empty() )
308 return;
309
310 VECTOR2I focusPt;
311 KIGFX::VIEW* view = GetCanvas()->GetView();
312 SHAPE_POLY_SET viewportPoly( view->GetViewport() );
313
314 for( wxWindow* dialog : findDialogs() )
315 {
316 wxPoint dialogPos = GetCanvas()->ScreenToClient( dialog->GetScreenPosition() );
317 SHAPE_POLY_SET dialogPoly( BOX2D( view->ToWorld( ToVECTOR2D( dialogPos ), true ),
318 view->ToWorld( ToVECTOR2D( dialog->GetSize() ), false ) ) );
319
320 try
321 {
322 viewportPoly.BooleanSubtract( dialogPoly, SHAPE_POLY_SET::PM_FAST );
323 }
324 catch( const std::exception& exc )
325 {
326 // This may be overkill and could be an assertion but we are more likely to
327 // find any clipper errors this way.
328 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
329 }
330 }
331
332 SHAPE_POLY_SET itemPoly, clippedPoly;
333
334 for( BOARD_ITEM* item : aItems )
335 {
336 if( item && item != DELETED_BOARD_ITEM::GetInstance() )
337 {
338 item->SetBrightened();
339
340 item->RunOnDescendants(
341 [&]( BOARD_ITEM* child )
342 {
343 child->SetBrightened();
344 });
345
346 GetCanvas()->GetView()->Update( item );
347 lastBrightenedItemIDs.push_back( item->m_Uuid );
348
349 // Focus on the object's location. Prefer a visible part of the object to its anchor
350 // in order to keep from scrolling around.
351
352 focusPt = item->GetPosition();
353
354 if( aLayer == UNDEFINED_LAYER && item->GetLayerSet().any() )
355 aLayer = item->GetLayerSet().Seq()[0];
356
357 switch( item->Type() )
358 {
359 case PCB_FOOTPRINT_T:
360 try
361 {
362 itemPoly = static_cast<FOOTPRINT*>( item )->GetBoundingHull();
363 }
364 catch( const std::exception& exc )
365 {
366 // This may be overkill and could be an assertion but we are more likely to
367 // find any clipper errors this way.
368 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
369 }
370
371 break;
372
373 case PCB_PAD_T:
374 case PCB_MARKER_T:
375 case PCB_VIA_T:
376 FocusOnLocation( item->GetFocusPosition() );
377 GetCanvas()->Refresh();
378 return;
379
380 case PCB_SHAPE_T:
381 case PCB_FIELD_T:
382 case PCB_TEXT_T:
383 case PCB_TEXTBOX_T:
384 case PCB_TRACE_T:
385 case PCB_ARC_T:
387 case PCB_DIM_LEADER_T:
388 case PCB_DIM_CENTER_T:
389 case PCB_DIM_RADIAL_T:
391 item->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ),
392 ERROR_INSIDE );
393 break;
394
395 case PCB_ZONE_T:
396 {
397 ZONE* zone = static_cast<ZONE*>( item );
398 #if 0
399 // Using the filled area shapes to find a Focus point can give good results, but
400 // unfortunately the calculations are highly time consuming, even for not very
401 // large areas (can be easily a few minutes for large areas).
402 // so we used only the zone outline that usually do not have too many vertices.
403 zone->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ),
404 ERROR_INSIDE );
405
406 if( itemPoly.IsEmpty() )
407 itemPoly = *zone->Outline();
408 #else
409 // much faster calculation time when using only the zone outlines
410 itemPoly = *zone->Outline();
411 #endif
412
413 break;
414 }
415
416 default:
417 {
418 BOX2I item_bbox = item->GetBoundingBox();
419 itemPoly.NewOutline();
420 itemPoly.Append( item_bbox.GetOrigin() );
421 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(), 0 ) );
422 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( 0, item_bbox.GetHeight() ) );
423 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(),
424 item_bbox.GetHeight() ) );
425 break;
426 }
427 }
428
429 try
430 {
431 clippedPoly.BooleanIntersection( itemPoly, viewportPoly, SHAPE_POLY_SET::PM_FAST );
432 }
433 catch( const std::exception& exc )
434 {
435 // This may be overkill and could be an assertion but we are more likely to
436 // find any clipper errors this way.
437 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
438 }
439
440 if( !clippedPoly.IsEmpty() )
441 itemPoly = clippedPoly;
442 }
443 }
444
445 /*
446 * Perform a step-wise deflate to find the visual-center-of-mass
447 */
448
449 BOX2I bbox = itemPoly.BBox();
450 int step = std::min( bbox.GetWidth(), bbox.GetHeight() ) / 10;
451
452 while( !itemPoly.IsEmpty() )
453 {
454 focusPt = itemPoly.BBox().Centre();
455
456 try
457 {
458 itemPoly.Deflate( step, CORNER_STRATEGY::ALLOW_ACUTE_CORNERS, ARC_LOW_DEF );
459 }
460 catch( const std::exception& exc )
461 {
462 // This may be overkill and could be an assertion but we are more likely to
463 // find any clipper errors this way.
464 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
465 }
466 }
467
468 FocusOnLocation( focusPt );
469
470 GetCanvas()->Refresh();
471}
472
473
475{
476 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
477
478 if( view && GetBoard()->m_SolderMaskBridges && view->HasItem( GetBoard()->m_SolderMaskBridges ) )
479 view->Remove( GetBoard()->m_SolderMaskBridges );
480}
481
482
484{
485 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
486
487 if( view && GetBoard()->m_SolderMaskBridges )
488 {
489 if( view->HasItem( GetBoard()->m_SolderMaskBridges ) )
490 view->Remove( GetBoard()->m_SolderMaskBridges );
491
492 view->Add( GetBoard()->m_SolderMaskBridges );
493 }
494}
495
496
497void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
498{
499 m_pcb->SetPageSettings( aPageSettings );
500
501 if( GetScreen() )
503}
504
505
507{
508 return m_pcb->GetPageSettings();
509}
510
511
513{
514 // this function is only needed because EDA_DRAW_FRAME is not compiled
515 // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
516 // into an application specific source file.
518}
519
520
522{
524}
525
526
528{
530}
531
532
534{
536}
537
538
540{
541 VECTOR2I origin( 0, 0 );
542
543 switch( GetPcbNewSettings()->m_Display.m_DisplayOrigin )
544 {
545 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE: break;
546 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
547 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID: origin = GetGridOrigin(); break;
548 default: wxASSERT( false ); break;
549 }
550
551 return origin;
552}
553
555{
556 return m_originTransforms;
557}
558
559
561{
562 return m_pcb->GetTitleBlock();
563}
564
565
567{
568 m_pcb->SetTitleBlock( aTitleBlock );
569}
570
571
573{
574 return m_pcb->GetDesignSettings();
575}
576
577
579{
580 m_drawBgColor= aColor;
581 m_auimgr.Update();
582}
583
584
586{
587 return m_pcb->GetPlotOptions();
588}
589
590
592{
593 m_pcb->SetPlotOptions( aSettings );
594
595 // Plot Settings can also change the "tent vias" setting, which can affect the solder mask.
596 LSET visibleLayers = GetBoard()->GetVisibleLayers();
597
598 if( visibleLayers.test( F_Mask ) || visibleLayers.test( B_Mask ) )
599 {
601 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
602 {
603 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItem );
604
605 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to
606 // visible as they won't be found in the view layer's itemset for re-painting.
607 if( item && item->Type() == PCB_VIA_T )
608 return KIGFX::ALL;
609
610 return 0;
611 } );
612
613 GetCanvas()->Refresh();
614 }
615}
616
617
618BOX2I PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
619{
620 BOX2I area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
621
622 if( area.GetWidth() == 0 && area.GetHeight() == 0 )
623 {
624 VECTOR2I pageSize = GetPageSizeIU();
625
627 {
628 area.SetOrigin( 0, 0 );
629 area.SetEnd( pageSize.x, pageSize.y );
630 }
631 else
632 {
633 area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
634 area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
635 }
636 }
637
638 return area;
639}
640
641
642const BOX2I PCB_BASE_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
643{
644 /* "Zoom to Fit" calls this with "aIncludeAllVisible" as true. Since that feature
645 * always ignored the page and border, this function returns a bbox without them
646 * as well when passed true. This technically is not all things visible, but it
647 * keeps behavior consistent.
648 *
649 * When passed false, this function returns a bbox of just the board edge. This
650 * allows things like fabrication text or anything else outside the board edge to
651 * be ignored, and just zooms up to the board itself.
652 *
653 * Calling "GetBoardBoundingBox(true)" when edge cuts are turned off will return
654 * the entire page and border, so we call "GetBoardBoundingBox(false)" instead.
655 */
656 if( aIncludeAllVisible || !m_pcb->IsLayerVisible( Edge_Cuts ) )
657 return GetBoardBoundingBox( false );
658 else
659 return GetBoardBoundingBox( true );
660}
661
662
663// Virtual function
665{
666}
667
668
670{
671 // call my base class
673
674 // tooltips in toolbars
676
678
679 if( viewer3D )
680 viewer3D->ShowChangedLanguage();
681}
682
683
685{
686 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
687
688 if( !draw3DFrame )
689 draw3DFrame = new EDA_3D_VIEWER_FRAME( &Kiway(), this, _( "3D Viewer" ) );
690
691 // Raising the window does not show the window on Windows if iconized. This should work
692 // on any platform.
693 if( draw3DFrame->IsIconized() )
694 draw3DFrame->Iconize( false );
695
696 draw3DFrame->Raise();
697 draw3DFrame->Show( true );
698
699 // Raising the window does not set the focus on Linux. This should work on any platform.
700 if( wxWindow::FindFocus() != draw3DFrame )
701 draw3DFrame->SetFocus();
702
703 // Allocate a slice of time to display the 3D frame
704 // a call to wxSafeYield() should be enough (and better), but on Linux we need
705 // to call wxYield()
706 // otherwise the activity messages are not displayed during the first board loading
707 wxYield();
708
709 // Note, the caller is responsible to load/update the board 3D view.
710 // after frame creation the board is not automatically created.
711
712 return draw3DFrame;
713}
714
715
717{
718 PCB_LAYER_ID preslayer = GetActiveLayer();
719 auto& displ_opts = GetDisplayOptions();
720
721 // Check if the specified layer matches the present layer
722 if( layer == preslayer )
723 return;
724
725 // Copper layers cannot be selected unconditionally; how many of those layers are
726 // currently enabled needs to be checked.
727 if( IsCopperLayer( layer ) )
728 {
729 // If only one copper layer is enabled, the only such layer that can be selected to
730 // is the "Copper" layer (so the selection of any other copper layer is disregarded).
731 if( m_pcb->GetCopperLayerCount() < 2 )
732 {
733 if( layer != B_Cu )
734 return;
735 }
736
737 // If more than one copper layer is enabled, the "Copper" and "Component" layers
738 // can be selected, but the total number of copper layers determines which internal
739 // layers are also capable of being selected.
740 else
741 {
742 if( layer != B_Cu && layer != F_Cu && layer >= ( m_pcb->GetCopperLayerCount() - 1 ) )
743 return;
744 }
745 }
746
747 // Is yet more checking required? E.g. when the layer to be selected is a non-copper
748 // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
749 // ...
750
751 SetActiveLayer( layer );
752
753 if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
754 GetCanvas()->Refresh();
755}
756
757
759{
761 GetCanvas()->GetView() );
762
763 // account for the globals
778
779 return guide;
780}
781
782
784{
786
787 BASE_SCREEN* screen = GetScreen();
788
789 if( !screen )
790 return;
791
792 wxString line;
794
795 if( GetShowPolarCoords() ) // display polar coordinates
796 {
797 double dx = cursorPos.x - screen->m_LocalOrigin.x;
798 double dy = cursorPos.y - screen->m_LocalOrigin.y;
799 double theta = RAD2DEG( atan2( -dy, dx ) );
800 double ro = hypot( dx, dy );
801
802 line.Printf( wxT( "r %s theta %.3f" ),
803 MessageTextFromValue( ro, false ),
804 theta );
805
806 SetStatusText( line, 3 );
807 }
808
809 // Transform absolute coordinates for user origin preferences
810 double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
811 double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
812
813 // Display absolute coordinates:
814 line.Printf( wxT( "X %s Y %s" ),
815 MessageTextFromValue( userXpos, false ),
816 MessageTextFromValue( userYpos, false ) );
817 SetStatusText( line, 2 );
818
819 if( !GetShowPolarCoords() ) // display relative cartesian coordinates
820 {
821 // Calculate relative coordinates
822 double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
823 double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
824
825 // Transform relative coordinates for user origin preferences
826 userXpos = m_originTransforms.ToDisplayRelX( relXpos );
827 userYpos = m_originTransforms.ToDisplayRelY( relYpos );
828
829 line.Printf( wxT( "dx %s dy %s dist %s" ),
830 MessageTextFromValue( userXpos, false ),
831 MessageTextFromValue( userYpos, false ),
832 MessageTextFromValue( hypot( userXpos, userYpos ), false ) );
833 SetStatusText( line, 3 );
834 }
835
837}
838
839
841{
842 EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
843
844 if( GetBoard() )
846
848}
849
850
852{
854
855 if( aCfg->m_Window.grid.grids.empty() )
856 aCfg->m_Window.grid.grids = aCfg->DefaultGridSizeList();
857
858 // Move legacy user grids to grid list
859 if( !aCfg->m_Window.grid.user_grid_x.empty() )
860 {
861 aCfg->m_Window.grid.grids.emplace_back( GRID{ "User Grid", aCfg->m_Window.grid.user_grid_x,
862 aCfg->m_Window.grid.user_grid_y } );
863 aCfg->m_Window.grid.user_grid_x = wxEmptyString;
864 aCfg->m_Window.grid.user_grid_y = wxEmptyString;
865 }
866
867 // Currently values read from config file are not used because the user cannot
868 // change this config
869 // if( aCfg->m_Window.zoom_factors.empty() )
870 {
871 if( ADVANCED_CFG::GetCfg().m_HyperZoom )
873 else
875 }
876
877 // Some, but not all, derived classes have a PCBNEW_SETTINGS.
878 if( PCBNEW_SETTINGS* pcbnew_cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg ) )
879 m_polarCoords = pcbnew_cfg->m_PolarCoords;
880
881 wxASSERT( GetCanvas() );
882
883 if( GetCanvas() )
884 {
886
887 if( rs )
888 {
891 rs->SetDefaultFont( wxEmptyString ); // Always the KiCad font for PCBs
892 }
893 }
894}
895
896
898{
899 if( aErrorCode >= CLEANUP_FIRST )
900 return RPT_SEVERITY_ACTION;
901
903
904 return bds.m_DRCSeverities[ aErrorCode ];
905}
906
907
909{
911
912 // Some, but not all derived classes have a PCBNEW_SETTINGS.
913 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
914
915 if( cfg )
917}
918
919
921{
923}
924
925
927{
929}
930
931
933{
934 switch( GetFrameType() )
935 {
936 case FRAME_PCB_EDITOR:
938 default:
940
944
948 case FRAME_CVPCB:
951 }
952}
953
954
956{
958}
959
960
961void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
962{
963 EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
964
965 KIGFX::VIEW* view = GetCanvas()->GetView();
966 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
967 PCB_RENDER_SETTINGS* settings = painter->GetSettings();
968
969 settings->LoadColors( GetColorSettings( true ) );
972
973 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
974 // they won't be found in the view layer's itemset for re-painting.
976 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
977 {
978 if( dynamic_cast<RATSNEST_VIEW_ITEM*>( aItem ) )
979 {
980 return KIGFX::ALL; // ratsnest display
981 }
982 else if( dynamic_cast<PCB_TRACK*>( aItem ) )
983 {
984 return KIGFX::REPAINT; // track, arc & via clearance display
985 }
986 else if( dynamic_cast<PAD*>( aItem ) )
987 {
988 return KIGFX::REPAINT; // pad clearance display
989 }
990
991 return 0;
992 } );
993
995
997
998 // The 3D viewer isn't in the Kiway, so send its update manually
1000
1001 if( viewer )
1002 viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1003}
1004
1005
1007{
1009
1011 m_autoSaveRequired = true;
1012
1014
1017}
1018
1019
1021{
1025}
1026
1027
1029{
1030 return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
1031}
1032
1033
1035{
1037
1038 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
1039 KIGFX::VIEW* view = canvas->GetView();
1040
1041 if( m_toolManager )
1042 {
1043 m_toolManager->SetEnvironment( m_pcb, view, canvas->GetViewControls(), config(), this );
1044
1046 }
1047
1048 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
1049 KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
1050 const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
1051
1052 settings->LoadDisplayOptions( displ_opts );
1053 settings->LoadColors( GetColorSettings() );
1055
1056 view->RecacheAllItems();
1058 canvas->StartDrawing();
1059
1060 try
1061
1062 {
1063 if( m_spaceMouse == nullptr )
1064 {
1066 }
1067 }
1068 catch( const std::system_error& e )
1069 {
1070 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
1071 }
1072}
1073
1074
1075void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh )
1076{
1078 bool hcVisChanged = m_displayOptions.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN
1079 || aOptions.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN;
1080 m_displayOptions = aOptions;
1081
1082 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
1083 KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
1084
1085 view->UpdateDisplayOptions( aOptions );
1088
1089 // Vias on a restricted layer set must be redrawn when high contrast mode is changed
1090 if( hcChanged )
1091 {
1092 bool showNetNames = false;
1093
1094 if( PCBNEW_SETTINGS* config = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
1095 showNetNames = config->m_Display.m_NetNames > 0;
1096
1097 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
1098 // they won't be found in the view layer's itemset for re-painting.
1100 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1101 {
1102 if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( aItem ) )
1103 {
1104 if( via->GetViaType() == VIATYPE::BLIND_BURIED
1105 || via->GetViaType() == VIATYPE::MICROVIA
1106 || via->GetRemoveUnconnected()
1107 || showNetNames )
1108 {
1109 return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
1110 }
1111 }
1112 else if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
1113 {
1114 if( pad->GetRemoveUnconnected()
1115 || showNetNames )
1116 {
1117 return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
1118 }
1119 }
1120
1121 return 0;
1122 } );
1123 }
1124
1125 if( aRefresh )
1126 canvas->Refresh();
1127}
1128
1129
1131{
1132 wxLogTrace( "KICAD_LIB_WATCH", "setFPWatcher" );
1133
1134 Unbind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
1135
1136 if( m_watcher )
1137 {
1138 wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" );
1139 m_watcher->RemoveAll();
1140 m_watcher->SetOwner( nullptr );
1141 m_watcher.reset();
1142 }
1143
1144 wxString libfullname;
1146
1147 if( !aFootprint || !tbl )
1148 return;
1149
1150 try
1151 {
1152 const FP_LIB_TABLE_ROW* row = tbl->FindRow( aFootprint->GetFPID().GetLibNickname() );
1153
1154 if( !row )
1155 return;
1156
1157 libfullname = row->GetFullURI( true );
1158 }
1159 catch( const std::exception& e )
1160 {
1161 DisplayInfoMessage( this, e.what() );
1162 return;
1163 }
1164 catch( const IO_ERROR& error )
1165 {
1166 wxLogTrace( "KICAD_LIB_WATCH", "Error: %s", error.What() );
1167 return;
1168 }
1169
1170 m_watcherFileName.Assign( libfullname, aFootprint->GetFPID().GetLibItemName(),
1172
1173 if( !m_watcherFileName.FileExists() )
1174 return;
1175
1176 m_watcherLastModified = m_watcherFileName.GetModificationTime();
1177
1178 Bind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
1179 m_watcher = std::make_unique<wxFileSystemWatcher>();
1180 m_watcher->SetOwner( this );
1181
1182 wxFileName fn;
1183 fn.AssignDir( m_watcherFileName.GetPath() );
1184 fn.DontFollowLink();
1185
1186 wxLogTrace( "KICAD_LIB_WATCH", "Add watch: %s", fn.GetPath() );
1187
1188 m_watcher->Add( fn );
1189}
1190
1191
1192void PCB_BASE_FRAME::OnFPChange( wxFileSystemWatcherEvent& aEvent )
1193{
1194 if( aEvent.GetPath() != m_watcherFileName.GetFullPath() )
1195 return;
1196
1197 // Start the debounce timer (set to 1 second)
1198 if( !m_watcherDebounceTimer.StartOnce( 1000 ) )
1199 {
1200 wxLogTrace( "KICAD_LIB_WATCH", "Failed to start the debounce timer" );
1201 return;
1202 }
1203}
1204
1205
1207{
1208 wxLogTrace( "KICAD_LIB_WATCH", "OnFpChangeDebounceTimer" );
1209
1210 // Disable logging to avoid spurious messages and check if the file has changed
1211 wxLog::EnableLogging( false );
1212 wxDateTime lastModified = m_watcherFileName.GetModificationTime();
1213 wxLog::EnableLogging( true );
1214
1215 if( lastModified == m_watcherLastModified || !lastModified.IsValid() )
1216 return;
1217
1218 m_watcherLastModified = lastModified;
1219
1222
1223 // When loading a footprint from a library in the footprint editor
1224 // the items UUIDs must be keep and not reinitialized
1225 bool keepUUID = IsType( FRAME_FOOTPRINT_EDITOR );
1226
1227 if( !fp || !tbl )
1228 return;
1229
1231 || IsOK( this, _( "The library containing the current footprint has changed.\n"
1232 "Do you want to reload the footprint?" ) ) )
1233 {
1234 wxString fpname = fp->GetFPID().GetLibItemName();
1235 wxString nickname = fp->GetFPID().GetLibNickname();
1236
1237 try
1238 {
1239 FOOTPRINT* newfp = tbl->FootprintLoad( nickname, fpname, keepUUID );
1240
1241 if( newfp )
1242 {
1243 std::vector<KIID> selectedItems;
1244
1245 for( const EDA_ITEM* item : GetCurrentSelection() )
1246 {
1247 wxString uuidStr = item->m_Uuid.AsString();
1248 selectedItems.emplace_back( item->m_Uuid );
1249 }
1250
1252
1253 ReloadFootprint( newfp );
1254
1255 newfp->ClearAllNets();
1259
1260 std::vector<EDA_ITEM*> sel;
1261
1262 for( const KIID& uuid : selectedItems )
1263 {
1264 BOARD_ITEM* item = GetBoard()->GetItem( uuid );
1265
1266 if( item != DELETED_BOARD_ITEM::GetInstance() )
1267 sel.push_back( item );
1268 }
1269
1270 if( !sel.empty() )
1272 }
1273 }
1274 catch( const IO_ERROR& ioe )
1275 {
1276 DisplayError( this, ioe.What() );
1277 }
1278 }
1279}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr int ARC_LOW_DEF
Definition: base_units.h:119
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
BOX2< VECTOR2D > BOX2D
Definition: box2.h:878
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:92
WINDOW_SETTINGS m_Window
Definition: app_settings.h:172
const std::vector< GRID > 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()
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
virtual void RunOnDescendants(const std::function< void(BOARD_ITEM *)> &aFunction, int aDepth=0) const
Invoke a function on all descendants.
Definition: board_item.h:201
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: board.h:675
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:691
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:882
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:911
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:897
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:743
const PAGE_INFO & GetPageSettings() const
Definition: board.h:671
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition: board.cpp:1213
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:1290
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:176
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:433
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:677
int GetCopperLayerCount() const
Definition: board.cpp:653
void IncrementTimeStamp()
Definition: board.cpp:245
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:672
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:674
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:683
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:794
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:679
void SetUserUnits(EDA_UNITS aUnits)
Definition: board.h:684
void SetOrigin(const Vec &pos)
Definition: box2.h:227
const Vec & GetOrigin() const
Definition: box2.h:200
size_type GetHeight() const
Definition: box2.h:205
size_type GetWidth() const
Definition: box2.h:204
Vec Centre() const
Definition: box2.h:87
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:280
static DELETED_BOARD_ITEM * GetInstance()
Definition: board_item.h:432
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
void ShowChangedLanguage() override
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.
bool IsType(FRAME_T aType) const
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()
virtual void DisplayGridMsg()
Display current grid size in the status bar.
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
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:88
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:126
const KIID m_Uuid
Definition: eda_item.h:485
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
void ClearBrightened()
Definition: eda_item.h:122
void SetBrightened()
Definition: eda_item.h:119
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
Definition: actions.h:264
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2315
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2387
bool IsFlipped() const
Definition: footprint.h:377
const LIB_ID & GetFPID() const
Definition: footprint.h:233
void ClearAllNets()
Clear (i.e.
Definition: footprint.cpp:959
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:2256
VECTOR2I GetPosition() const override
Definition: footprint.h:209
Hold a record identifying a library accessed by the appropriate footprint library #PLUGIN object in t...
Definition: fp_lib_table.h:42
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...
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:323
void SetIgnoreBlindBuriedVias(bool ignore)
Definition: collectors.h:469
void SetIgnoreTracks(bool ignore)
Definition: collectors.h:475
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:409
void SetIgnoreModulesOnFront(bool ignore)
Definition: collectors.h:433
void SetIgnoreModulesRefs(bool ignore)
Definition: collectors.h:463
void SetIgnoreMicroVias(bool ignore)
Definition: collectors.h:472
void SetIgnorePadsOnBack(bool ignore)
Definition: collectors.h:439
void SetIgnoreModulesOnBack(bool ignore)
Definition: collectors.h:427
void SetIgnoreModulesVals(bool ignore)
Definition: collectors.h:457
void SetIgnoreThroughVias(bool ignore)
Definition: collectors.h:466
void SetIgnoreThroughHolePads(bool ignore)
Definition: collectors.h:451
void SetIgnoreMTextsOnFront(bool ignore)
Definition: collectors.h:421
void SetIgnoreMTextsOnBack(bool ignore)
Definition: collectors.h:415
void SetIgnorePadsOnFront(bool ignore)
Definition: collectors.h:445
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
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
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:165
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:170
PCB specific render settings.
Definition: pcb_painter.h:78
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:75
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:57
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:66
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:103
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:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:512
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
Definition: view.cpp:1617
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:449
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1410
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1513
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
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:1523
Definition: kiid.h:49
wxString AsString() const
Definition: kiid.cpp:257
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...
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:575
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:53
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:59
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:171
DISPLAY_OPTIONS m_Display
MAGNETIC_SETTINGS m_MagneticItems
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: pcb_actions.h:76
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 BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
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
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.
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)
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.
void UpdateColors()
Update the color settings in the painter and GAL.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplayBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
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.
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
A progress reporter interface for use in multi-threaded environments.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
static void Cleanup3DCache(PROJECT *aProject)
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
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.
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:167
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:169
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
Definition: tools_holder.h:98
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
@ 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.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
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) const
A lower-precision version of StringFromValue().
EDA_UNITS GetUserUnits() const
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
SHAPE_POLY_SET * Outline()
Definition: zone.h:336
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:1353
@ 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:241
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:161
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:213
This file is part of the common library.
#define _(s)
Declaration of the eda_3d_viewer class.
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:435
#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:42
@ FRAME_CVPCB_DISPLAY
Definition: frame_type.h:53
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:45
@ FRAME_FOOTPRINT_WIZARD
Definition: frame_type.h:46
@ FRAME_FOOTPRINT_PREVIEW
Definition: frame_type.h:48
@ FRAME_FOOTPRINT_CHOOSER
Definition: frame_type.h:44
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:43
@ FRAME_PCB_DISPLAY3D
Definition: frame_type.h:47
@ FRAME_CVPCB
Definition: frame_type.h:52
@ ERROR_INSIDE
static const std::string KiCadFootprintFileExtension
KIID niluuid(0)
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:881
@ LAYER_FOOTPRINTS_FR
show footprints on front
Definition: layer_ids.h:212
@ LAYER_FP_REFERENCES
show footprints references (when texts are visible)
Definition: layer_ids.h:215
@ LAYER_HIDDEN_TEXT
text marked as invisible
Definition: layer_ids.h:204
@ LAYER_TRACKS
Definition: layer_ids.h:216
@ LAYER_FP_TEXT
Definition: layer_ids.h:202
@ LAYER_FOOTPRINTS_BK
show footprints on back
Definition: layer_ids.h:213
@ LAYER_PADS_SMD_BK
smd pads, back layer
Definition: layer_ids.h:207
@ LAYER_PADS_TH
multilayer pads, usually with holes
Definition: layer_ids.h:217
@ LAYER_PADS_SMD_FR
smd pads, front layer
Definition: layer_ids.h:206
@ LAYER_FP_VALUES
show footprints values (when texts are visible)
Definition: layer_ids.h:214
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:197
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_Mask
Definition: layer_ids.h:106
@ B_Cu
Definition: layer_ids.h:95
@ F_Mask
Definition: layer_ids.h:107
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
Message panel definition file.
@ COLOR
Color has changed.
Definition: view_item.h:53
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:58
Declaration of the NL_PCBNEW_PLUGIN class.
wxDEFINE_EVENT(EDA_EVT_BOARD_CHANGED, wxCommandEvent)
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
SEVERITY
@ RPT_SEVERITY_ACTION
KIWAY Kiway(KFCTL_STANDALONE)
float highlight_factor
How much to brighten highlighted objects by.
Definition: app_settings.h:110
float select_factor
How much to brighten selected objects by.
Definition: app_settings.h:111
const double IU_PER_MILS
Definition: base_units.h:77
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
wxString user_grid_x
Definition: grid_settings.h:67
std::vector< GRID > grids
Definition: grid_settings.h:66
wxString user_grid_y
Definition: grid_settings.h:68
Common grid settings, available to every frame.
Definition: grid_settings.h:34
GRID_SETTINGS grid
Definition: app_settings.h:81
std::vector< double > zoom_factors
Definition: app_settings.h:78
double RAD2DEG(double rad)
Definition: trigo.h:201
@ 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:105
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:103
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:107
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition: typeinfo.h:90
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:99
@ 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:101
@ 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:98
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:104
VECTOR2< int > VECTOR2I
Definition: vector2d.h:602
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
#define ZOOM_LIST_PCBNEW_HYPER
Definition: zoom_defines.h:35