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 The 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 <lset.h>
47#include <kiface_base.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>
54#include <project_pcb.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
70#ifdef __linux__
72#else
74#endif
75
78
79wxDEFINE_EVENT( EDA_EVT_BOARD_CHANGING, wxCommandEvent );
80wxDEFINE_EVENT( EDA_EVT_BOARD_CHANGED, wxCommandEvent );
81
82PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
83 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
84 long aStyle, const wxString& aFrameName ) :
85 EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, pcbIUScale ),
86 m_pcb( nullptr ),
87 m_originTransforms( *this ),
89{
91}
92
93
95{
96 // Ensure m_canvasType is up to date, to save it in config
97 if( GetCanvas() )
99
100 delete m_pcb;
101 m_pcb = nullptr;
102}
103
104
105bool PCB_BASE_FRAME::canCloseWindow( wxCloseEvent& aEvent )
106{
107 // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
108 // board.
109 wxWindow* viewer3D = Get3DViewerFrame();
110
111 if( viewer3D )
112 viewer3D->Close( true );
113
114 // Similarly, wxConvBrokenFileNames uses some statically allocated variables that make it
115 // crash when run later from a d'tor.
117
118 return true;
119}
120
121
122void PCB_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
123{
125
126 if( m_spaceMouse )
127 m_spaceMouse->SetFocus( aEvent.GetActive() );
128}
129
130
131void PCB_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
132{
134
135 if( m_spaceMouse && aEvent.IsIconized() )
136 m_spaceMouse->SetFocus( false );
137}
138
139
141{
142 wxWindow* frame = FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) );
143 return dynamic_cast<EDA_3D_VIEWER_FRAME*>( frame );
144}
145
146
147void PCB_BASE_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
148{
149 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
150
151 if( draw3DFrame )
152 {
153 if( aTitle )
154 draw3DFrame->SetTitle( *aTitle );
155
156 if( aMarkDirty )
157 draw3DFrame->ReloadRequest();
158
159 if( aRefresh )
160 draw3DFrame->Redraw();
161 }
162}
163
164
166{
167 if( m_pcb != aBoard )
168 {
169 delete m_pcb;
170 m_pcb = aBoard;
171
172 if( GetBoard() )
174
175 if( GetBoard() && GetCanvas() )
176 {
178
179 if( rs )
180 {
181 rs->SetDashLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineDashRatio() );
182 rs->SetGapLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineGapRatio() );
183 }
184 }
185
186 wxCommandEvent e( EDA_EVT_BOARD_CHANGED );
187 ProcessEventLocally( e );
188 }
189}
190
191
193{
194 if( aFootprint )
195 {
196 GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
197
198 aFootprint->SetFlags( IS_NEW );
199 aFootprint->SetPosition( VECTOR2I( 0, 0 ) ); // cursor in GAL may not be initialized yet
200
201 // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
202 // built from a board)
203 if( aFootprint->IsFlipped() )
204 aFootprint->Flip( aFootprint->GetPosition(), GetPcbNewSettings()->m_FlipDirection );
205
206 // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
207 // it might be stored in another orientation if the lib is an archive built from a board)
208 aFootprint->SetOrientation( ANGLE_0 );
209
210 GetBoard()->UpdateUserUnits( aFootprint, GetCanvas()->GetView() );
211
213 }
214}
215
216
217EDA_ITEM* PCB_BASE_FRAME::ResolveItem( const KIID& aId, bool aAllowNullptrReturn ) const
218{
219 return GetBoard()->ResolveItem( aId, aAllowNullptrReturn );
220}
221
222void PCB_BASE_FRAME::FocusOnItem( EDA_ITEM* aItem, bool aAllowScroll )
223{
224 // nullptr will clear the current focus
225 if( aItem != nullptr && !aItem->IsBOARD_ITEM() )
226 return;
227
228 FocusOnItem( static_cast<BOARD_ITEM*>( aItem ), UNDEFINED_LAYER, aAllowScroll );
229}
230
231void PCB_BASE_FRAME::FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, bool aAllowScroll )
232{
233 std::vector<BOARD_ITEM*> items;
234
235 if( aItem )
236 items.push_back( aItem );
237
238 FocusOnItems( items, aLayer, aAllowScroll );
239}
240
241
242void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID aLayer, bool aAllowScroll )
243{
244 static std::vector<KIID> lastBrightenedItemIDs;
245
246 bool itemsUnbrightened = false;
247
248 for( KIID lastBrightenedItemID : lastBrightenedItemIDs )
249 {
250 if( BOARD_ITEM* lastItem = GetBoard()->ResolveItem( lastBrightenedItemID, true ) )
251 {
252 lastItem->ClearBrightened();
253 GetCanvas()->GetView()->Update( lastItem );
254 itemsUnbrightened = true;
255 }
256 }
257
258 if( itemsUnbrightened )
259 GetCanvas()->Refresh();
260
261 lastBrightenedItemIDs.clear();
262
263 if( aItems.empty() )
264 return;
265
266 VECTOR2I focusPt;
267 KIGFX::VIEW* view = GetCanvas()->GetView();
268 SHAPE_POLY_SET viewportPoly( view->GetViewport() );
269
270 for( wxWindow* dialog : findDialogs() )
271 {
272 wxPoint dialogPos = GetCanvas()->ScreenToClient( dialog->GetScreenPosition() );
273 SHAPE_POLY_SET dialogPoly( BOX2D( view->ToWorld( ToVECTOR2D( dialogPos ), true ),
274 view->ToWorld( ToVECTOR2D( dialog->GetSize() ), false ) ) );
275
276 try
277 {
278 viewportPoly.BooleanSubtract( dialogPoly );
279 }
280 catch( const std::exception& e )
281 {
282 wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
283 }
284 }
285
286 SHAPE_POLY_SET itemPoly, clippedPoly;
287
288 for( BOARD_ITEM* item : aItems )
289 {
290 if( item && item != DELETED_BOARD_ITEM::GetInstance() )
291 {
292 item->SetBrightened();
293 lastBrightenedItemIDs.push_back( item->m_Uuid );
294
295 item->RunOnChildren(
296 [&]( BOARD_ITEM* child )
297 {
298 child->SetBrightened();
299 lastBrightenedItemIDs.push_back( child->m_Uuid );
300 },
302
303 GetCanvas()->GetView()->Update( item );
304
305 // Focus on the object's location. Prefer a visible part of the object to its anchor
306 // in order to keep from scrolling around.
307
308 focusPt = item->GetPosition();
309
310 if( aLayer == UNDEFINED_LAYER && item->GetLayerSet().any() )
311 aLayer = item->GetLayerSet().Seq()[0];
312
313 switch( item->Type() )
314 {
315 case PCB_FOOTPRINT_T:
316 try
317 {
318 itemPoly = static_cast<FOOTPRINT*>( item )->GetBoundingHull();
319 }
320 catch( const std::exception& e )
321 {
322 wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
323 }
324
325 break;
326
327 case PCB_PAD_T:
328 case PCB_MARKER_T:
329 case PCB_VIA_T:
330 FocusOnLocation( item->GetFocusPosition(), aAllowScroll );
331 GetCanvas()->Refresh();
332 return;
333
334 case PCB_SHAPE_T:
335 case PCB_FIELD_T:
336 case PCB_TEXT_T:
337 case PCB_TEXTBOX_T:
338 case PCB_BARCODE_T:
339 case PCB_TRACE_T:
340 case PCB_ARC_T:
342 case PCB_DIM_LEADER_T:
343 case PCB_DIM_CENTER_T:
344 case PCB_DIM_RADIAL_T:
346 item->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ), ERROR_INSIDE );
347 break;
348
349 case PCB_ZONE_T:
350 {
351 ZONE* zone = static_cast<ZONE*>( item );
352#if 0
353 // Using the filled area shapes to find a Focus point can give good results, but
354 // unfortunately the calculations are highly time consuming, even for not very
355 // large areas (can be easily a few minutes for large areas).
356 // so we used only the zone outline that usually do not have too many vertices.
357 zone->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ), ERROR_INSIDE );
358
359 if( itemPoly.IsEmpty() )
360 itemPoly = *zone->Outline();
361#else
362 // much faster calculation time when using only the zone outlines
363 itemPoly = *zone->Outline();
364#endif
365
366 break;
367 }
368
369 default:
370 {
371 BOX2I item_bbox = item->GetBoundingBox();
372 itemPoly.NewOutline();
373 itemPoly.Append( item_bbox.GetOrigin() );
374 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(), 0 ) );
375 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( 0, item_bbox.GetHeight() ) );
376 itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(),
377 item_bbox.GetHeight() ) );
378 break;
379 }
380 }
381
382 try
383 {
384 itemPoly.ClearArcs();
385 viewportPoly.ClearArcs();
386 clippedPoly.BooleanIntersection( itemPoly, viewportPoly );
387 }
388 catch( const std::exception& e )
389 {
390 wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
391 }
392
393 if( !clippedPoly.IsEmpty() )
394 itemPoly = clippedPoly;
395 }
396 }
397
398 /*
399 * Perform a step-wise deflate to find the visual-center-of-mass
400 */
401
402 BOX2I bbox = itemPoly.BBox();
403 int step = std::min( bbox.GetWidth(), bbox.GetHeight() ) / 10;
404
405 while( !itemPoly.IsEmpty() )
406 {
407 focusPt = itemPoly.BBox().Centre();
408
409 try
410 {
412 }
413 catch( const std::exception& e )
414 {
415 wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
416 }
417 }
418
419 FocusOnLocation( focusPt, aAllowScroll );
420
421 GetCanvas()->Refresh();
422}
423
424
426{
427 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
428
429 if( view && GetBoard()->m_SolderMaskBridges && view->HasItem( GetBoard()->m_SolderMaskBridges ) )
430 view->Remove( GetBoard()->m_SolderMaskBridges );
431}
432
433
435{
436 KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
437
438 if( view && GetBoard()->m_SolderMaskBridges )
439 {
440 if( view->HasItem( GetBoard()->m_SolderMaskBridges ) )
441 view->Remove( GetBoard()->m_SolderMaskBridges );
442
443 view->Add( GetBoard()->m_SolderMaskBridges );
444 }
445}
446
447
448void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
449{
450 m_pcb->SetPageSettings( aPageSettings );
451
452 if( GetScreen() )
453 GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( pcbIUScale.IU_PER_MILS ) );
454}
455
456
458{
459 return m_pcb->GetPageSettings();
460}
461
462
464{
465 // this function is only needed because EDA_DRAW_FRAME is not compiled
466 // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
467 // into an application specific source file.
468 return m_pcb->GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS );
469}
470
471
473{
474 return m_pcb->GetDesignSettings().GetGridOrigin();
475}
476
477
479{
480 m_pcb->GetDesignSettings().SetGridOrigin( aPoint );
481}
482
483
485{
486 return m_pcb->GetDesignSettings().GetAuxOrigin();
487}
488
489
491{
492 VECTOR2I origin( 0, 0 );
493
494 switch( GetPcbNewSettings()->m_Display.m_DisplayOrigin )
495 {
497 case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
499 default: wxASSERT( false ); break;
500 }
501
502 return origin;
503}
504
509
510
512{
513 return m_pcb->GetTitleBlock();
514}
515
516
518{
519 m_pcb->SetTitleBlock( aTitleBlock );
520}
521
522
524{
525 return m_pcb->GetDesignSettings();
526}
527
528
530{
531 m_drawBgColor= aColor;
532 m_auimgr.Update();
533}
534
535
537{
538 return m_pcb->GetPlotOptions();
539}
540
541
543{
544 m_pcb->SetPlotOptions( aSettings );
545
546 // Plot Settings can also change the "tent vias" setting, which can affect the solder mask.
547 LSET visibleLayers = GetBoard()->GetVisibleLayers();
548
549 if( visibleLayers.test( F_Mask ) || visibleLayers.test( B_Mask ) )
550 {
552 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
553 {
554 BOARD_ITEM* item = nullptr;
555
556 if( aItem->IsBOARD_ITEM() )
557 item = static_cast<BOARD_ITEM*>( aItem );
558
559 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to
560 // visible as they won't be found in the view layer's itemset for re-painting.
561 if( item && item->Type() == PCB_VIA_T )
562 return KIGFX::ALL;
563
564 return 0;
565 } );
566
567 GetCanvas()->Refresh();
568 }
569}
570
571
572BOX2I PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
573{
574 BOX2I area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
575
576 if( area.GetWidth() == 0 && area.GetHeight() == 0 )
577 {
578 VECTOR2I pageSize = GetPageSizeIU();
579
581 {
582 area.SetOrigin( 0, 0 );
583 area.SetEnd( pageSize.x, pageSize.y );
584 }
585 else
586 {
587 area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
588 area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
589 }
590 }
591
592 return area;
593}
594
595
596const BOX2I PCB_BASE_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
597{
598 /* "Zoom to Fit" calls this with "aIncludeAllVisible" as true. Since that feature
599 * always ignored the page and border, this function returns a bbox without them
600 * as well when passed true. This technically is not all things visible, but it
601 * keeps behavior consistent.
602 *
603 * When passed false, this function returns a bbox of just the board edge. This
604 * allows things like fabrication text or anything else outside the board edge to
605 * be ignored, and just zooms up to the board itself.
606 *
607 * Calling "GetBoardBoundingBox(true)" when edge cuts are turned off will return
608 * the entire page and border, so we call "GetBoardBoundingBox(false)" instead.
609 */
610 if( aIncludeAllVisible || !m_pcb->IsLayerVisible( Edge_Cuts ) )
611 return GetBoardBoundingBox( false );
612 else
613 return GetBoardBoundingBox( true );
614}
615
616
617// Virtual function
621
622
624{
625 // call my base class
627
628 // tooltips in toolbars
630
632
633 if( viewer3D )
634 viewer3D->ShowChangedLanguage();
635}
636
637
639{
640 EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
641
642 if( !draw3DFrame )
643 draw3DFrame = new EDA_3D_VIEWER_FRAME( &Kiway(), this, _( "3D Viewer" ) );
644
645 // Raising the window does not show the window on Windows if iconized. This should work
646 // on any platform.
647 if( draw3DFrame->IsIconized() )
648 draw3DFrame->Iconize( false );
649
650 draw3DFrame->Raise();
651 draw3DFrame->Show( true );
652
653 // Raising the window does not set the focus on Linux. This should work on any platform.
654 if( wxWindow::FindFocus() != draw3DFrame )
655 draw3DFrame->SetFocus();
656
657 // Allocate a slice of time to display the 3D frame
658 // a call to wxSafeYield() should be enough (and better), but on Linux we need
659 // to call wxYield()
660 // otherwise the activity messages are not displayed during the first board loading
661 wxYield();
662
663 // Note, the caller is responsible to load/update the board 3D view.
664 // after frame creation the board is not automatically created.
665
666 return draw3DFrame;
667}
668
669
671{
672 PCB_LAYER_ID preslayer = GetActiveLayer();
673 auto& displ_opts = GetDisplayOptions();
674
675 // Check if the specified layer matches the present layer
676 if( layer == preslayer )
677 return;
678
679 // Copper layers cannot be selected unconditionally; how many of those layers are
680 // currently enabled needs to be checked.
681 if( IsCopperLayer( layer ) )
682 {
683 if( layer > m_pcb->GetCopperLayerStackMaxId() )
684 return;
685 }
686
687 // Is yet more checking required? E.g. when the layer to be selected is a non-copper
688 // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
689 // ...
690
691 SetActiveLayer( layer );
692
693 if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
694 GetCanvas()->Refresh();
695}
696
697
699{
700 GENERAL_COLLECTORS_GUIDE guide( m_pcb->GetVisibleLayers(), GetActiveLayer(),
701 GetCanvas()->GetView() );
702
703 // account for the globals
704 guide.SetIgnoreFPTextOnBack( !m_pcb->IsElementVisible( LAYER_FP_TEXT ) );
705 guide.SetIgnoreFPTextOnFront( !m_pcb->IsElementVisible( LAYER_FP_TEXT ) );
706 guide.SetIgnoreFootprintsOnBack( !m_pcb->IsElementVisible( LAYER_FOOTPRINTS_BK ) );
707 guide.SetIgnoreFootprintsOnFront( !m_pcb->IsElementVisible( LAYER_FOOTPRINTS_FR ) );
708 guide.SetIgnoreThroughHolePads( ! m_pcb->IsElementVisible( LAYER_PADS ) );
709 guide.SetIgnoreFPValues( !m_pcb->IsElementVisible( LAYER_FP_VALUES ) );
710 guide.SetIgnoreFPReferences( !m_pcb->IsElementVisible( LAYER_FP_REFERENCES ) );
711 guide.SetIgnoreThroughVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
712 guide.SetIgnoreBlindBuriedVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
713 guide.SetIgnoreMicroVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
714 guide.SetIgnoreTracks( ! m_pcb->IsElementVisible( LAYER_TRACKS ) );
715
716 return guide;
717}
718
719
721{
723
724 BASE_SCREEN* screen = GetScreen();
725
726 if( !screen )
727 return;
728
729 wxString line;
731
732 if( GetShowPolarCoords() ) // display polar coordinates
733 {
734 double dx = cursorPos.x - screen->m_LocalOrigin.x;
735 double dy = cursorPos.y - screen->m_LocalOrigin.y;
736 double theta = RAD2DEG( atan2( -dy, dx ) );
737 double ro = hypot( dx, dy );
738
739 line.Printf( wxT( "r %s theta %.3f" ),
740 MessageTextFromValue( ro, false ),
741 theta );
742
743 SetStatusText( line, 3 );
744 }
745
746 // Transform absolute coordinates for user origin preferences
747 double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
748 double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
749
750 // Display absolute coordinates:
751 line.Printf( wxT( "X %s Y %s" ),
752 MessageTextFromValue( userXpos, false ),
753 MessageTextFromValue( userYpos, false ) );
754 SetStatusText( line, 2 );
755
756 if( !GetShowPolarCoords() ) // display relative cartesian coordinates
757 {
758 // Calculate relative coordinates
759 double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
760 double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
761
762 // Transform relative coordinates for user origin preferences
763 userXpos = m_originTransforms.ToDisplayRelX( relXpos );
764 userYpos = m_originTransforms.ToDisplayRelY( relYpos );
765
766 line.Printf( wxT( "dx %s dy %s dist %s" ),
767 MessageTextFromValue( userXpos, false ),
768 MessageTextFromValue( userYpos, false ),
769 MessageTextFromValue( hypot( userXpos, userYpos ), false ) );
770 SetStatusText( line, 3 );
771 }
772
774}
775
776
778{
779 EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
780
781 if( GetBoard() )
783
785}
786
787
789{
791
792 // Move legacy user grids to grid list
793 if( !aCfg->m_Window.grid.user_grid_x.empty() )
794 {
795 aCfg->m_Window.grid.grids.emplace_back( GRID{ "User Grid", aCfg->m_Window.grid.user_grid_x,
796 aCfg->m_Window.grid.user_grid_y } );
797 aCfg->m_Window.grid.user_grid_x = wxEmptyString;
798 aCfg->m_Window.grid.user_grid_y = wxEmptyString;
799 }
800
801 // Some, but not all, derived classes have a PCBNEW_SETTINGS.
802 if( PCBNEW_SETTINGS* pcbnew_cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg ) )
803 m_polarCoords = pcbnew_cfg->m_PolarCoords;
804
805 wxASSERT( GetCanvas() );
806
807 if( GetCanvas() )
808 {
810
811 if( rs )
812 {
815 rs->SetDefaultFont( wxEmptyString ); // Always the KiCad font for PCBs
816 }
817 }
818}
819
820
822{
823 if( aErrorCode >= CLEANUP_FIRST )
824 return RPT_SEVERITY_ACTION;
825
827
828 return bds.m_DRCSeverities[ aErrorCode ];
829}
830
831
833{
835
836 // Some, but not all derived classes have a PCBNEW_SETTINGS.
837 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
838
839 if( cfg )
841}
842
843
848
849
854
855
877
878
880{
881 static MAGNETIC_SETTINGS fallback;
882
884 return &cfg->m_MagneticItems;
885
886 return &fallback;
887}
888
889
891{
893
894 KIGFX::VIEW* view = GetCanvas()->GetView();
895 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
896 PCB_RENDER_SETTINGS* settings = painter->GetSettings();
897
898 settings->LoadColors( GetColorSettings( true ) );
901
902 if( aFlags & TEXTVARS_CHANGED )
904
905 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
906 // they won't be found in the view layer's itemset for re-painting.
908 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
909 {
910 if( dynamic_cast<RATSNEST_VIEW_ITEM*>( aItem ) )
911 {
912 return KIGFX::ALL; // ratsnest display
913 }
914 else if( dynamic_cast<PCB_TRACK*>( aItem ) )
915 {
916 return KIGFX::REPAINT; // track, arc & via clearance display
917 }
918 else if( dynamic_cast<PAD*>( aItem ) )
919 {
920 return KIGFX::REPAINT; // pad clearance display
921 }
922 else if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
923 {
924 if( text->HasTextVars() )
925 {
926 text->ClearRenderCache();
927 text->ClearBoundingBoxCache();
929 }
930 }
931
932 return 0;
933 } );
934
936
938
939 // The 3D viewer isn't in the Kiway, so send its update manually
941
942 if( viewer )
943 viewer->CommonSettingsChanged( aFlags );
944}
945
946
948{
950
953
954 if( m_isClosing )
955 return;
956
959}
960
961
968
969
974
975
977{
979
980 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
981 KIGFX::VIEW* view = canvas->GetView();
982
983 if( m_toolManager )
984 {
985 m_toolManager->SetEnvironment( m_pcb, view, canvas->GetViewControls(), config(), this );
986
988 }
989
990 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
991 KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
992 const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
993
994 settings->LoadDisplayOptions( displ_opts );
995 settings->LoadColors( GetColorSettings() );
997
998 view->RecacheAllItems();
1000 canvas->StartDrawing();
1001
1002 try
1003
1004 {
1005 if( !m_spaceMouse )
1006 {
1007#ifndef __linux__
1008 m_spaceMouse = std::make_unique<NL_PCBNEW_PLUGIN>( GetCanvas() );
1009#else
1010 m_spaceMouse = std::make_unique<SPNAV_2D_PLUGIN>( GetCanvas() );
1011 m_spaceMouse->SetScale( 0.01 );
1012#endif
1013 }
1014 }
1015 catch( const std::system_error& e )
1016 {
1017 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
1018 }
1019}
1020
1021
1022void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh )
1023{
1024 bool hcChanged = m_displayOptions.m_ContrastModeDisplay != aOptions.m_ContrastModeDisplay;
1025 bool hcVisChanged = m_displayOptions.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN
1027 m_displayOptions = aOptions;
1028
1029 EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
1030 KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
1031
1032 view->UpdateDisplayOptions( aOptions );
1035
1036 // Vias on a restricted layer set must be redrawn when high contrast mode is changed
1037 if( hcChanged )
1038 {
1039 bool showNetNames = false;
1040
1041 if( PCBNEW_SETTINGS* config = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
1042 showNetNames = config->m_Display.m_NetNames > 0;
1043
1044 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
1045 // they won't be found in the view layer's itemset for re-painting.
1047 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1048 {
1049 if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( aItem ) )
1050 {
1051 if( via->GetViaType() != VIATYPE::THROUGH
1052 || via->GetRemoveUnconnected()
1053 || showNetNames )
1054 {
1055 return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
1056 }
1057 }
1058 else if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
1059 {
1060 if( pad->GetRemoveUnconnected()
1061 || showNetNames )
1062 {
1063 return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
1064 }
1065 }
1066
1067 return 0;
1068 } );
1069 }
1070
1071 if( aRefresh )
1072 canvas->Refresh();
1073}
1074
1075
1077{
1078 wxLogTrace( "KICAD_LIB_WATCH", "setFPWatcher" );
1079
1080 Unbind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
1081
1082 if( m_watcher )
1083 {
1084 wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" );
1085 m_watcher->RemoveAll();
1086 m_watcher->SetOwner( nullptr );
1087 m_watcher.reset();
1088 }
1089
1090 wxString libfullname;
1092
1093 if( !aFootprint || !tbl )
1094 return;
1095
1096 try
1097 {
1098 const FP_LIB_TABLE_ROW* row = tbl->FindRow( aFootprint->GetFPID().GetLibNickname() );
1099
1100 if( !row )
1101 return;
1102
1103 libfullname = row->GetFullURI( true );
1104 }
1105 catch( const std::exception& e )
1106 {
1107 DisplayInfoMessage( this, e.what() );
1108 return;
1109 }
1110 catch( const IO_ERROR& error )
1111 {
1112 wxLogTrace( "KICAD_LIB_WATCH", "Error: %s", error.What() );
1113 return;
1114 }
1115
1116 m_watcherFileName.Assign( libfullname, aFootprint->GetFPID().GetLibItemName(),
1118
1119 if( !m_watcherFileName.FileExists() )
1120 return;
1121
1122 m_watcherLastModified = m_watcherFileName.GetModificationTime();
1123
1124 Bind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
1125 m_watcher = std::make_unique<wxFileSystemWatcher>();
1126 m_watcher->SetOwner( this );
1127
1128 wxFileName fn;
1129 fn.AssignDir( m_watcherFileName.GetPath() );
1130 fn.DontFollowLink();
1131
1132 wxLogTrace( "KICAD_LIB_WATCH", "Add watch: %s", fn.GetPath() );
1133
1134 {
1135 // Silence OS errors that come from the watcher
1136 wxLogNull silence;
1137 m_watcher->Add( fn );
1138 }
1139}
1140
1141
1142void PCB_BASE_FRAME::OnFPChange( wxFileSystemWatcherEvent& aEvent )
1143{
1144 if( aEvent.GetPath() != m_watcherFileName.GetFullPath() )
1145 return;
1146
1147 // Start the debounce timer (set to 1 second)
1148 if( !m_watcherDebounceTimer.StartOnce( 1000 ) )
1149 {
1150 wxLogTrace( "KICAD_LIB_WATCH", "Failed to start the debounce timer" );
1151 return;
1152 }
1153}
1154
1155
1157{
1158 if( aEvent.GetId() != m_watcherDebounceTimer.GetId() )
1159 {
1160 aEvent.Skip();
1161 return;
1162 }
1163
1165 {
1166 wxLogTrace( "KICAD_LIB_WATCH", "Restarting debounce timer" );
1167 m_watcherDebounceTimer.StartOnce( 3000 );
1168 }
1169
1170 wxLogTrace( "KICAD_LIB_WATCH", "OnFpChangeDebounceTimer" );
1171
1172 // Disable logging to avoid spurious messages and check if the file has changed
1173 wxLog::EnableLogging( false );
1174 wxDateTime lastModified = m_watcherFileName.GetModificationTime();
1175 wxLog::EnableLogging( true );
1176
1177 if( lastModified == m_watcherLastModified || !lastModified.IsValid() )
1178 return;
1179
1180 m_watcherLastModified = lastModified;
1181
1184
1185 // When loading a footprint from a library in the footprint editor
1186 // the items UUIDs must be keep and not reinitialized
1187 bool keepUUID = IsType( FRAME_FOOTPRINT_EDITOR );
1188
1189 if( !fp || !tbl )
1190 return;
1191
1193
1195 || IsOK( this, _( "The library containing the current footprint has changed.\n"
1196 "Do you want to reload the footprint?" ) ) )
1197 {
1198 wxString fpname = fp->GetFPID().GetLibItemName();
1199 wxString nickname = fp->GetFPID().GetLibNickname();
1200
1201 try
1202 {
1203 FOOTPRINT* newfp = tbl->FootprintLoad( nickname, fpname, keepUUID );
1204
1205 if( newfp )
1206 {
1207 std::vector<KIID> selectedItems;
1208
1209 for( const EDA_ITEM* item : GetCurrentSelection() )
1210 selectedItems.emplace_back( item->m_Uuid );
1211
1213
1214 ReloadFootprint( newfp );
1215
1216 newfp->ClearAllNets();
1220
1221 std::vector<EDA_ITEM*> sel;
1222
1223 for( const KIID& uuid : selectedItems )
1224 {
1225 if( BOARD_ITEM* item = GetBoard()->ResolveItem( uuid, true ) )
1226 sel.push_back( item );
1227 }
1228
1229 if( !sel.empty() )
1230 m_toolManager->RunAction( ACTIONS::selectItems, &sel );
1231 }
1232 }
1233 catch( const IO_ERROR& ioe )
1234 {
1235 DisplayError( this, ioe.What() );
1236 }
1237 }
1238
1239 m_inFpChangeTimerEvent = false;
1240}
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
constexpr int ARC_LOW_DEF
Definition base_units.h:128
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
BOX2< VECTOR2D > BOX2D
Definition box2.h:923
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition actions.h:231
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
WINDOW_SETTINGS m_Window
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)
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:79
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1164
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition board.cpp:1663
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:938
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:189
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition board.h:505
void IncrementTimeStamp()
Definition board.cpp:257
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1041
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition board.cpp:2404
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
Definition board.cpp:1742
void SetUserUnits(EDA_UNITS aUnits)
Definition board.h:771
constexpr void SetOrigin(const Vec &pos)
Definition box2.h:237
constexpr size_type GetWidth() const
Definition box2.h:214
constexpr Vec Centre() const
Definition box2.h:97
constexpr size_type GetHeight() const
Definition box2.h:215
constexpr const Vec & GetOrigin() const
Definition box2.h:210
constexpr void SetEnd(coord_type x, coord_type y)
Definition box2.h:297
static DELETED_BOARD_ITEM * GetInstance()
Definition board_item.h:490
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
void CommonSettingsChanged(int aFlags) override
Notification that common settings are updated.
void ShowChangedLanguage() override
void ReloadRequest()
Request reloading the 3D view.
FRAME_T GetFrameType() const
virtual APP_SETTINGS_BASE * config() const
Return 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.
virtual void RecreateToolbars()
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
bool IsType(FRAME_T aType) const
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
The current canvas type.
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.
EDA_DRAW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
virtual void UpdateMsgPanel()
Redraw the message panel.
void FocusOnLocation(const VECTOR2I &aPos, bool aAllowScroll=true)
Useful to focus on a particular location, in find functions.
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 ...
std::vector< wxWindow * > findDialogs()
virtual void DisplayGridMsg()
Display current grid size in the status bar.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
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:98
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:142
const KIID m_Uuid
Definition eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
void SetBrightened()
Definition eda_item.h:135
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:80
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
Definition actions.h:350
void SetPosition(const VECTOR2I &aPos) override
void SetOrientation(const EDA_ANGLE &aNewAngle)
bool IsFlipped() const
Definition footprint.h:434
const LIB_ID & GetFPID() const
Definition footprint.h:269
void ClearAllNets()
Clear (i.e.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetPosition() const override
Definition footprint.h:245
Hold a record identifying a library accessed by the appropriate footprint library #PLUGIN object in t...
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:324
void SetIgnoreBlindBuriedVias(bool ignore)
Definition collectors.h:464
void SetIgnoreTracks(bool ignore)
Definition collectors.h:470
void SetIgnoreFootprintsOnFront(bool ignore)
Definition collectors.h:428
void SetIgnoreFPTextOnFront(bool ignore)
Definition collectors.h:416
void SetIgnoreMicroVias(bool ignore)
Definition collectors.h:467
void SetIgnoreFPTextOnBack(bool ignore)
Definition collectors.h:410
void SetIgnoreThroughVias(bool ignore)
Definition collectors.h:461
void SetIgnoreThroughHolePads(bool ignore)
Definition collectors.h:446
void SetIgnoreFPReferences(bool ignore)
Definition collectors.h:458
void SetIgnoreFPValues(bool ignore)
Definition collectors.h:452
void SetIgnoreFootprintsOnBack(bool ignore)
Definition collectors.h:422
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
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.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
Definition pcb_painter.h:82
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:91
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:74
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition pcb_view.cpp:149
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:86
bool IsBOARD_ITEM() const
Definition view_item.h:102
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:66
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition view.cpp:530
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
Definition view.cpp:1671
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:467
void RecacheAllItems()
Rebuild GAL display lists.
Definition view.cpp:1451
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1561
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:220
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:1571
Definition kiid.h:49
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:286
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 lset.h:37
A class to perform either relative or absolute display origin transforms for a single axis of a point...
Definition pad.h:54
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:79
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition page_info.h:177
DISPLAY_OPTIONS m_Display
static TOOL_ACTION rehatchShapes
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 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.
std::unique_ptr< NL_PCBNEW_PLUGIN > m_spaceMouse
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 handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
void setFPWatcher(FOOTPRINT *aFootprint)
Create 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 ...
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box 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()
void FocusOnItems(std::vector< BOARD_ITEM * > aItems, PCB_LAYER_ID aLayer=UNDEFINED_LAYER, bool aAllowScroll=true)
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.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
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).
EDA_ITEM * ResolveItem(const KIID &aId, bool aAllowNullptrReturn=false) const override
Fetch an item by KIID.
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
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
Return the BOARD_DESIGN_SETTINGS for the open project.
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
virtual void doReCreateMenuBar() override
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Update the current display options.
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
void FocusOnItem(EDA_ITEM *aItem, bool aAllowScroll=true) override
Focus on a particular canvas item.
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()
Show 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
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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.
Parameters and options when plotting/printing a board.
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:125
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.
static void Cleanup3DCache(PROJECT *aProject)
T * GetAppSettings(const char *aFilename)
Return a handle to the a given settings by type.
Represent a set of closed polygons.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
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)
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
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
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
@ 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.
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:74
SHAPE_POLY_SET * Outline()
Definition zone.h:335
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:1577
@ CLEANUP_FIRST
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition confirm.cpp:251
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:222
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:169
This file is part of the common library.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
#define _(s)
Declaration of the eda_3d_viewer class.
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
@ RECURSE
Definition eda_item.h:51
#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
static const std::string KiCadFootprintFileExtension
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:676
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
Definition layer_ids.h:259
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
Definition layer_ids.h:266
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
Definition layer_ids.h:292
@ LAYER_TRACKS
Definition layer_ids.h:267
@ LAYER_FP_TEXT
Definition layer_ids.h:240
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
Definition layer_ids.h:260
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
Definition layer_ids.h:263
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition layer_ids.h:232
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ Edge_Cuts
Definition layer_ids.h:112
@ B_Mask
Definition layer_ids.h:98
@ F_Mask
Definition layer_ids.h:97
@ UNDEFINED_LAYER
Definition layer_ids.h:61
Message panel definition file.
@ COLOR
Color has changed.
Definition view_item.h:54
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:58
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:55
@ ALL
All except INITIAL_ADD.
Definition view_item.h:59
Declaration of the NL_PCBNEW_PLUGIN class.
wxDEFINE_EVENT(EDA_EVT_BOARD_CHANGING, wxCommandEvent)
@ THROUGH
Definition pcb_track.h:68
@ PCB_ORIGIN_AUX
@ PCB_ORIGIN_GRID
@ PCB_ORIGIN_PAGE
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:913
see class PGM_BASE
SEVERITY
@ RPT_SEVERITY_ACTION
KIWAY Kiway(KFCTL_STANDALONE)
float highlight_factor
How much to brighten highlighted objects by.
float select_factor
How much to brighten selected objects by.
wxString user_grid_x
std::vector< GRID > grids
wxString user_grid_y
Common grid settings, available to every frame.
GRID_SETTINGS grid
#define TEXTVARS_CHANGED
double RAD2DEG(double rad)
Definition trigo.h:167
@ 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:106
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:103
@ 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:104
@ 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:108
@ 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_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:101
@ 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:102
@ 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:105
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)
Definition vector2wx.h:40
Definition of file extensions used in Kicad.