KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_draw_panel_gal.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) 2014-2017 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "pcb_draw_panel_gal.h"
27
28#include <pcb_view.h>
30#include <pcb_painter.h>
33
34#include <board.h>
35#include <footprint.h>
36#include <pcb_track.h>
37#include <macros.h>
38#include <pcb_generator.h>
39#include <pcb_marker.h>
40#include <pcb_point.h>
41#include <pcb_base_frame.h>
42#include <pcbnew_settings.h>
45#include <pcb_board_outline.h>
46
47#include <pgm_base.h>
49#include <confirm.h>
50#include <progress_reporter.h>
51#include <string_utils.h>
52
54#include <zoom_defines.h>
55
56#include <functional>
57#include <memory>
58#include <thread>
59#include <fmt/format.h>
60
61using namespace std::placeholders;
62
63
64const int GAL_LAYER_ORDER[] =
65{
76
80
89
135
137
139
147
153 // POINT_LAYER_FOR( F_Cu ),
161
282
296
301
347
355
386
394
396
398};
399
400
401PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
402 const wxPoint& aPosition, const wxSize& aSize,
403 KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
404 EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType )
405{
406 m_view = new KIGFX::PCB_VIEW();
407 m_view->SetGAL( m_gal );
408
410
411 if( EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( aParentWindow ) )
412 frameType = frame->GetFrameType();
413
414 m_painter = std::make_unique<KIGFX::PCB_PAINTER>( m_gal, frameType );
415 m_view->SetPainter( m_painter.get() );
416
417 // This fixes the zoom in and zoom out limits:
419
422
423 // View controls is the first in the event handler chain, so the Tool Framework operates
424 // on updated viewport data.
426
427 // Load display options (such as filled/outline display of items).
428 // Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
429 // which is not always the case (namely when it is used from a wxDialog like the pad editor)
430 if( !IsDialogPreview() )
431 {
432 KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( m_view );
433 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
434
435 if( frame )
436 view->UpdateDisplayOptions( frame->GetDisplayOptions() );
437 }
438}
439
440
444
445
447{
448 m_view->Clear();
449
450 aBoard->CacheTriangulation( aReporter );
451
452 if( m_drawingSheet )
453 m_drawingSheet->SetFileName( TO_UTF8( aBoard->GetFileName() ) );
454
455 // Load drawings
456 for( BOARD_ITEM* drawing : aBoard->Drawings() )
457 m_view->Add( drawing );
458
459 // Load tracks
460 for( PCB_TRACK* track : aBoard->Tracks() )
461 m_view->Add( track );
462
463 // Load footprints and its additional elements
464 for( FOOTPRINT* footprint : aBoard->Footprints() )
465 m_view->Add( footprint );
466
467 // DRC markers
468 for( PCB_MARKER* marker : aBoard->Markers() )
469 m_view->Add( marker );
470
471 // Load points
472 for( PCB_POINT* point : aBoard->Points() )
473 m_view->Add( point );
474
475 // Load zones
476 for( ZONE* zone : aBoard->Zones() )
477 m_view->Add( zone );
478
479 for( PCB_GENERATOR* generator : aBoard->Generators() )
480 m_view->Add( generator );
481
482 aBoard->UpdateBoardOutline();
483 m_view->Add( aBoard->BoardOutline() );
484
485 // Ratsnest
486 if( !aBoard->IsFootprintHolder() )
487 {
488 m_ratsnest = std::make_unique<RATSNEST_VIEW_ITEM>( aBoard->GetConnectivity() );
489 m_view->Add( m_ratsnest.get() );
490 }
491}
492
493
495{
496 m_drawingSheet.reset( aDrawingSheet );
497 m_view->Add( m_drawingSheet.get() );
498}
499
500
502{
504 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
505
506 if( frame )
507 cs = frame->GetColorSettings();
508 else if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
509 cs = ::GetColorSettings( cfg->m_ColorTheme );
510
511 wxCHECK_RET( cs, wxT( "null COLOR_SETTINGS" ) );
512
513 auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
514 rs->LoadColors( cs );
515
516 m_gal->SetGridColor( cs->GetColor( LAYER_GRID ) );
517 m_gal->SetAxesColor( cs->GetColor( LAYER_GRID_AXES ) );
518 m_gal->SetCursorColor( cs->GetColor( LAYER_CURSOR ) );
519}
520
521
523{
524 // Set display settings for high contrast mode
525 KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
526
527 SetTopLayer( aLayer );
528 rSettings->SetActiveLayer( aLayer );
529
530 rSettings->ClearHighContrastLayers();
531 rSettings->SetLayerIsHighContrast( aLayer );
532
533 if( IsCopperLayer( aLayer ) )
534 {
535 // Bring some other layers to the front in case of copper layers and make them colored
536 // fixme do not like the idea of storing the list of layers here,
537 // should be done in some other way I guess..
538 int layers[] = {
540 GetNetnameLayer( aLayer ),
543 PAD_COPPER_LAYER_FOR( aLayer ),
544 VIA_COPPER_LAYER_FOR( aLayer ),
545 ZONE_LAYER_FOR( aLayer ),
546 BITMAP_LAYER_FOR( aLayer ),
547 POINT_LAYER_FOR( aLayer ),
557 };
558
559 for( int i : layers )
560 rSettings->SetLayerIsHighContrast( i );
561
562 for( int i = LAYER_UI_START; i < LAYER_UI_END; ++i )
563 rSettings->SetLayerIsHighContrast( i );
564
565 // Pads should be shown too
566 if( aLayer == B_Cu )
567 {
569 }
570 else if( aLayer == F_Cu )
571 {
573 }
574 }
575
576 m_view->UpdateAllLayersColor();
577}
578
579
581{
582 m_view->ClearTopLayers();
584 m_view->SetTopLayer( aLayer );
585
586 // Layers that should always have on-top attribute enabled
587 const std::vector<int> layers = {
596 };
597
598 for( auto layer : layers )
599 m_view->SetTopLayer( layer );
600
601 for( int i = LAYER_UI_START; i < LAYER_UI_END; i++ )
602 m_view->SetTopLayer( i );
603
604 // Extra layers that are brought to the top if a F.* or B.* is selected
605 const std::vector<int> frontLayers = {
608 };
609
610 const std::vector<int> backLayers = {
613 };
614
615 const std::vector<int>* extraLayers = nullptr;
616
617 // Bring a few more extra layers to the top depending on the selected board side
618 if( IsFrontLayer( aLayer ) )
619 extraLayers = &frontLayers;
620 else if( IsBackLayer( aLayer ) )
621 extraLayers = &backLayers;
622
623 if( extraLayers )
624 {
625 for( auto layer : *extraLayers )
626 {
627 m_view->SetTopLayer( layer );
628
629 if( layer < PCB_LAYER_ID_COUNT )
630 {
631 m_view->SetTopLayer( ZONE_LAYER_FOR( layer ) );
632 m_view->SetTopLayer( PAD_COPPER_LAYER_FOR( layer ) );
633 m_view->SetTopLayer( VIA_COPPER_LAYER_FOR( layer ) );
634 m_view->SetTopLayer( CLEARANCE_LAYER_FOR( layer ) );
635 m_view->SetTopLayer( POINT_LAYER_FOR( layer ) );
636 }
637 }
638
639 // Move the active layer to the top of the stack but below all the overlay layers
640 if( !IsCopperLayer( aLayer ) )
641 {
642 m_view->SetLayerOrder( aLayer, m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 1 );
643 m_view->SetLayerOrder( ZONE_LAYER_FOR( aLayer ),
644 m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 2 );
645 m_view->SetLayerOrder( POINT_LAYER_FOR( aLayer ),
646 m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 3 );
647
648 // Fix up pad and via netnames to be below. This is hacky, we need a rethink
649 // of layer ordering...
650 m_view->SetLayerOrder( LAYER_PAD_NETNAMES,
651 m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 4 );
652 m_view->SetLayerOrder( LAYER_VIA_NETNAMES,
653 m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 5 );
654 }
655 }
656
657 if( IsCopperLayer( aLayer ) )
658 {
659 m_view->SetTopLayer( ZONE_LAYER_FOR( aLayer ) );
660 m_view->SetTopLayer( PAD_COPPER_LAYER_FOR( aLayer ) );
661 m_view->SetTopLayer( VIA_COPPER_LAYER_FOR( aLayer ) );
662 m_view->SetTopLayer( CLEARANCE_LAYER_FOR( aLayer ) );
663
664 // Display labels for copper layers on the top
665 m_view->SetTopLayer( GetNetnameLayer( aLayer ) );
666 }
667
668 m_view->SetTopLayer( POINT_LAYER_FOR( aLayer ) );
669 m_view->SetTopLayer( BITMAP_LAYER_FOR( aLayer ) );
670 m_view->EnableTopLayer( true );
671 m_view->UpdateAllLayersOrder();
672}
673
674
676{
677 // Load layer & elements visibility settings
678 for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
679 m_view->SetLayerVisible( i, aBoard->IsLayerVisible( PCB_LAYER_ID( i ) ) );
680
682 m_view->SetLayerVisible( i, aBoard->IsElementVisible( i ) );
683
684 // Via layers controlled by dependencies
685 m_view->SetLayerVisible( LAYER_VIA_MICROVIA, true );
686 m_view->SetLayerVisible( LAYER_VIA_BBLIND, true );
687 m_view->SetLayerVisible( LAYER_VIA_THROUGH, true );
688
689 // Always enable netname layers, as their visibility is controlled by layer dependencies
690 for( int i = NETNAMES_LAYER_ID_START; i < NETNAMES_LAYER_ID_END; ++i )
691 m_view->SetLayerVisible( i, true );
692
693 for( int i = LAYER_ZONE_START; i < LAYER_ZONE_END; i++ )
694 m_view->SetLayerVisible( i, true );
695
696 for( int i = LAYER_PAD_COPPER_START; i < LAYER_PAD_COPPER_END; i++ )
697 m_view->SetLayerVisible( i, true );
698
699 for( int i = LAYER_VIA_COPPER_START; i < LAYER_VIA_COPPER_END; i++ )
700 m_view->SetLayerVisible( i, true );
701
702 for( int i = LAYER_CLEARANCE_START; i < LAYER_CLEARANCE_END; i++ )
703 m_view->SetLayerVisible( i, false );
704
705 for( int i = LAYER_POINT_START; i < LAYER_POINT_END; i++ )
706 m_view->SetLayerVisible( i, true );
707
708 for( int i = LAYER_BITMAP_START; i < LAYER_BITMAP_END; i++ )
709 m_view->SetLayerVisible( i, true );
710
711 for( int i = LAYER_UI_START; i < LAYER_UI_END; i++ )
712 m_view->SetLayerVisible( i, true );
713
714 // Enable some layers that are GAL specific
715 m_view->SetLayerVisible( LAYER_PAD_PLATEDHOLES, true );
716 m_view->SetLayerVisible( LAYER_NON_PLATEDHOLES, true );
717 m_view->SetLayerVisible( LAYER_PAD_HOLEWALLS, true );
718 m_view->SetLayerVisible( LAYER_VIA_HOLES, true );
719 m_view->SetLayerVisible( LAYER_VIA_HOLEWALLS, true );
720 m_view->SetLayerVisible( LAYER_GP_OVERLAY, true );
721 m_view->SetLayerVisible( LAYER_SELECT_OVERLAY, true );
722 m_view->SetLayerVisible( LAYER_RATSNEST, true );
723 m_view->SetLayerVisible( LAYER_MARKER_SHADOWS, true );
724 m_view->SetLayerVisible( LAYER_DRC_SHAPES, true );
725}
726
727
729 std::vector<MSG_PANEL_ITEM>& aList )
730{
731 BOARD* board = static_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() )->GetBoard();
732 int padCount = 0;
733 int viaCount = 0;
734 int trackSegmentCount = 0;
735 std::set<int> netCodes;
736 int unconnected = (int) board->GetConnectivity()->GetUnconnectedCount( true );
737
738 for( PCB_TRACK* item : board->Tracks() )
739 {
740 if( item->Type() == PCB_VIA_T )
741 viaCount++;
742 else
743 trackSegmentCount++;
744
745 if( item->GetNetCode() > 0 )
746 netCodes.insert( item->GetNetCode() );
747 }
748
749 for( FOOTPRINT* footprint : board->Footprints() )
750 {
751 for( PAD* pad : footprint->Pads() )
752 {
753 padCount++;
754
755 if( pad->GetNetCode() > 0 )
756 netCodes.insert( pad->GetNetCode() );
757 }
758 }
759
760 aList.emplace_back( _( "Pads" ), fmt::format( "{}", padCount ) );
761 aList.emplace_back( _( "Vias" ), fmt::format( "{}", viaCount ) );
762 aList.emplace_back( _( "Track Segments" ), fmt::format( "{}", trackSegmentCount ) );
763 aList.emplace_back( _( "Nets" ), fmt::format( "{}", (int) netCodes.size() ) );
764 aList.emplace_back( _( "Unrouted" ), fmt::format( "{}", unconnected ) );
765}
766
767
769{
770 PCB_BASE_FRAME* frame = nullptr;
771
772 if( !IsDialogPreview() )
773 frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
774
775 try
776 {
777 // Check if the current rendering back end can be properly initialized
778 m_view->UpdateItems();
779 }
780 catch( const std::runtime_error& e )
781 {
782 DisplayError( GetParent(), e.what() );
783
784 // Use the fallback if we have one
785 if( GAL_FALLBACK != m_backend )
786 {
788
789 if( frame )
790 frame->ActivateGalCanvas();
791 }
792 }
793
794 if( frame )
795 {
796 SetTopLayer( frame->GetActiveLayer() );
797
798 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( m_view->GetPainter() );
799 KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
800
801 settings->LoadDisplayOptions( frame->GetDisplayOptions() );
803 }
804}
805
806
808{
809 for( int i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( int ); ++i )
810 {
811 int layer = GAL_LAYER_ORDER[i];
812 wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
813
814 // MW: Gross hack to make SetTopLayer bring the correct bitmap layer to
815 // the top of the other bitmaps, but still below all the other layers
816 if( layer >= LAYER_BITMAP_START && layer < LAYER_BITMAP_END )
817 m_view->SetLayerOrder( layer, i - KIGFX::VIEW::TOP_LAYER_MODIFIER );
818 else
819 m_view->SetLayerOrder( layer, i );
820 }
821}
822
823
825{
826 bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
828 m_gal->SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ );
829 return rv;
830}
831
832
834{
835 if( m_ratsnest )
836 m_view->Update( m_ratsnest.get() );
837}
838
839
841{
842 if( m_drawingSheet && m_view->IsLayerVisible( LAYER_DRAWINGSHEET ) )
843 return m_drawingSheet->ViewBBox();
844
845 return BOX2I();
846}
847
848
850{
851 // caching makes no sense for Cairo and other software renderers
853
854 for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; i++ )
855 m_view->SetLayerTarget( i, target );
856
857 for( int i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( int ); ++i )
858 {
859 int layer = GAL_LAYER_ORDER[i];
860 wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
861
862 // Set layer display dependencies & targets
863 if( IsCopperLayer( layer ) )
864 {
865 m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer );
866 m_view->SetRequired( PAD_COPPER_LAYER_FOR( layer ), layer );
867 m_view->SetRequired( VIA_COPPER_LAYER_FOR( layer ), layer );
868 m_view->SetRequired( CLEARANCE_LAYER_FOR( layer ), layer );
869 m_view->SetRequired( POINT_LAYER_FOR( layer ), layer );
870
871 m_view->SetRequired( BITMAP_LAYER_FOR( layer ), layer );
872 m_view->SetLayerTarget( BITMAP_LAYER_FOR( layer ), KIGFX::TARGET_NONCACHED );
873 m_view->SetRequired( GetNetnameLayer( layer ), layer );
874 }
875 else if( IsNonCopperLayer( layer ) )
876 {
877 m_view->SetRequired( POINT_LAYER_FOR( layer ), layer );
878 m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer );
879 m_view->SetLayerTarget( BITMAP_LAYER_FOR( layer ), KIGFX::TARGET_NONCACHED );
880 m_view->SetRequired( BITMAP_LAYER_FOR( layer ), layer );
881 }
882 else if( IsNetnameLayer( layer ) )
883 {
884 m_view->SetLayerDisplayOnly( layer );
885 }
886 }
887
888 m_view->SetLayerTarget( LAYER_ANCHOR, KIGFX::TARGET_NONCACHED );
889 m_view->SetLayerDisplayOnly( LAYER_ANCHOR );
890
891 // Use TARGET_OVERLAY for LAYER_CONFLICTS_SHADOW, it is for items
892 // that may change while the view stays the same.
894
895 m_view->SetLayerDisplayOnly( LAYER_LOCKED_ITEM_SHADOW );
896 m_view->SetLayerDisplayOnly( LAYER_CONFLICTS_SHADOW );
897 m_view->SetLayerDisplayOnly( LAYER_BOARD_OUTLINE_AREA );
898
899 // Some more required layers settings
900 m_view->SetRequired( LAYER_PAD_NETNAMES, LAYER_PADS );
901
902 // Holes can be independent of their host objects (cf: printing drill marks)
903 m_view->SetRequired( LAYER_VIA_HOLES, LAYER_VIAS );
904 m_view->SetRequired( LAYER_VIA_HOLEWALLS, LAYER_VIAS );
905 m_view->SetRequired( LAYER_PAD_PLATEDHOLES, LAYER_PADS );
906 m_view->SetRequired( LAYER_PAD_HOLEWALLS, LAYER_PADS );
907 m_view->SetRequired( LAYER_NON_PLATEDHOLES, LAYER_PADS );
908
909 // Via visibility
910 m_view->SetRequired( LAYER_VIA_MICROVIA, LAYER_VIAS );
911 m_view->SetRequired( LAYER_VIA_BBLIND, LAYER_VIAS );
912 m_view->SetRequired( LAYER_VIA_THROUGH, LAYER_VIAS );
913 m_view->SetRequired( LAYER_VIA_NETNAMES, LAYER_VIAS );
914
916 m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY ) ;
918 m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;
919 m_view->SetLayerTarget( LAYER_RATSNEST, KIGFX::TARGET_OVERLAY );
920 m_view->SetLayerDisplayOnly( LAYER_RATSNEST );
921
922 m_view->SetLayerTarget( LAYER_DRC_ERROR, KIGFX::TARGET_OVERLAY );
923 //m_view->SetLayerDisplayOnly( LAYER_DRC_ERROR );
925 //m_view->SetLayerDisplayOnly( LAYER_DRC_WARNING );
927 //m_view->SetLayerDisplayOnly( LAYER_DRC_EXCLUSION );
929 m_view->SetLayerDisplayOnly( LAYER_MARKER_SHADOWS );
931 m_view->SetLayerDisplayOnly( LAYER_DRC_SHAPES );
932
934 m_view->SetLayerDisplayOnly( LAYER_DRAWINGSHEET ) ;
935 m_view->SetLayerDisplayOnly( LAYER_GRID );
936
937 for( int i = LAYER_UI_START; i < LAYER_UI_END; ++i )
938 {
939 m_view->SetLayerTarget( i, KIGFX::TARGET_OVERLAY );
940 m_view->SetLayerDisplayOnly( i );
941 }
942}
943
944
946{
947 return static_cast<KIGFX::PCB_VIEW*>( m_view );
948}
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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:317
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition board.h:347
const GENERATORS & Generators() const
Definition board.h:364
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition board.cpp:989
PCB_BOARD_OUTLINE * BoardOutline()
Definition board.h:366
const PCB_POINTS & Points() const
Definition board.h:372
void UpdateBoardOutline()
Definition board.cpp:3246
const ZONES & Zones() const
Definition board.h:362
const MARKERS & Markers() const
Definition board.h:370
const FOOTPRINTS & Footprints() const
Definition board.h:358
const TRACKS & Tracks() const
Definition board.h:356
const wxString & GetFileName() const
Definition board.h:354
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:929
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:521
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
Definition board.cpp:1084
const DRAWINGS & Drawings() const
Definition board.h:360
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
unsigned int GetUnconnectedCount(bool aVisibileOnly) const
The base frame for deriving all KiCad main window classes.
The base class for create windows for drawing purpose.
static constexpr GAL_TYPE GAL_FALLBACK
std::unique_ptr< KIGFX::PAINTER > m_painter
Contains information about how to draw items using GAL.
KIGFX::GAL * m_gal
Interface for drawing objects on a 2D-surface.
EDA_DRAW_PANEL_GAL(wxWindow *aParentWindow, wxWindowID aWindowId, const wxPoint &aPosition, const wxSize &aSize, KIGFX::GAL_DISPLAY_OPTIONS &aOptions, GAL_TYPE aGalType=GAL_TYPE_OPENGL)
Create a drawing panel that is contained inside aParentWindow.
@ GAL_TYPE_OPENGL
OpenGL implementation.
KIGFX::VIEW * m_view
Stores view settings (scale, center, etc.) and items to be drawn.
KIGFX::WX_VIEW_CONTROLS * m_viewControls
Control for VIEW (moving, zooming, etc.)
virtual bool SwitchBackend(GAL_TYPE aGalType)
Switch method of rendering graphics.
GAL_TYPE m_backend
Currently used GAL.
EDA_DRAW_FRAME * GetParentEDAFrame() const
Returns parent EDA_DRAW_FRAME, if available or NULL otherwise.
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:81
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...
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 ClearHighContrastLayers()
Clear the list of active layers.
void SetActiveLayer(PCB_LAYER_ID aLayer)
void SetLayerIsHighContrast(int aLayerId, bool aEnabled=true)
Set the specified layer as high-contrast.
static constexpr int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
Definition view.h:748
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
Definition view.h:745
An implementation of class VIEW_CONTROLS for wxWidgets library.
Definition pad.h:54
DISPLAY_OPTIONS m_Display
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual PCB_LAYER_ID GetActiveLayer() const
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
void UpdateColors()
Update the color settings in the painter and GAL.
PCB_DRAW_PANEL_GAL(wxWindow *aParentWindow, wxWindowID aWindowId, const wxPoint &aPosition, const wxSize &aSize, KIGFX::GAL_DISPLAY_OPTIONS &aOptions, GAL_TYPE aGalType=GAL_TYPE_OPENGL)
BOX2I GetDefaultViewBBox() const override
Return the bounding box of the view that should be used if model is not valid.
virtual void SetTopLayer(int aLayer) override
SetTopLayer(), with some extra smarts for PCB.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Called when the window is shown for the first time.
std::unique_ptr< RATSNEST_VIEW_ITEM > m_ratsnest
Ratsnest view item.
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Sets (or updates) drawing-sheet used by the draw panel.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void OnShow() override
Called when the window is shown for the first time.
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 SyncLayersVisibility(const BOARD *aBoard)
Update "visibility" property of each layer of a given BOARD.
void setDefaultLayerOrder()
< Reassign layer order to the initial settings.
virtual void SetHighContrastLayer(int aLayer) override
SetHighContrastLayer(), with some extra smarts for PCB.
std::unique_ptr< DS_PROXY_VIEW_ITEM > m_drawingSheet
Currently used drawing-sheet.
bool SwitchBackend(GAL_TYPE aGalType) override
Force refresh of the ratsnest visual representation.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Definition pcb_point.h:43
A progress reporter interface for use in multi-threaded environments.
Handle a list of polygons defining a copper zone.
Definition zone.h:74
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.
#define _(s)
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:33
@ FRAME_FOOTPRINT_PREVIEW
Definition frame_type.h:48
@ LAYER_PAD_FR_NETNAMES
Additional netnames layers (not associated with a PCB layer).
Definition layer_ids.h:200
@ LAYER_PAD_BK_NETNAMES
Definition layer_ids.h:201
@ LAYER_PAD_NETNAMES
Definition layer_ids.h:202
@ NETNAMES_LAYER_ID_START
Definition layer_ids.h:194
@ NETNAMES_LAYER_ID_END
Definition layer_ids.h:205
@ LAYER_VIA_NETNAMES
Definition layer_ids.h:203
#define BITMAP_LAYER_FOR(boardLayer)
Macros for getting the extra layers for a given board layer.
Definition layer_ids.h:366
#define NETNAMES_LAYER_INDEX(layer)
Macro for obtaining netname layer for a given PCB layer.
Definition layer_ids.h:209
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition layer_ids.h:776
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition layer_ids.h:799
#define POINT_LAYER_FOR(boardLayer)
Definition layer_ids.h:371
bool IsNonCopperLayer(int aLayerId)
Test whether a layer is a non copper layer.
Definition layer_ids.h:707
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition layer_ids.h:850
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:674
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:228
@ LAYER_GRID
Definition layer_ids.h:253
@ LAYER_POINTS
PCB reference/manual snap points visibility.
Definition layer_ids.h:320
@ GAL_LAYER_ID_START
Definition layer_ids.h:229
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition layer_ids.h:306
@ LAYER_PAD_COPPER_START
Virtual layers for pad copper on a given copper layer.
Definition layer_ids.h:336
@ LAYER_VIA_HOLEWALLS
Definition layer_ids.h:297
@ LAYER_CLEARANCE_END
Definition layer_ids.h:345
@ LAYER_GRID_AXES
Definition layer_ids.h:254
@ LAYER_CONFLICTS_SHADOW
Shadow layer for items flagged conflicting.
Definition layer_ids.h:309
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
Definition layer_ids.h:258
@ LAYER_ZONE_END
Definition layer_ids.h:333
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
Definition layer_ids.h:238
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition layer_ids.h:277
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
Definition layer_ids.h:265
@ LAYER_BOARD_OUTLINE_AREA
PCB board outline.
Definition layer_ids.h:317
@ LAYER_DRC_EXCLUSION
Layer for DRC markers which have been individually excluded.
Definition layer_ids.h:303
@ LAYER_POINT_END
Definition layer_ids.h:353
@ LAYER_DRC_SHAPES
Custom shapes for DRC markers.
Definition layer_ids.h:314
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
Definition layer_ids.h:291
@ LAYER_DRC_WARNING
Layer for DRC markers with #SEVERITY_WARNING.
Definition layer_ids.h:300
@ LAYER_UI_START
Definition layer_ids.h:356
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition layer_ids.h:270
@ GAL_LAYER_ID_END
Definition layer_ids.h:359
@ LAYER_GP_OVERLAY
General purpose overlay.
Definition layer_ids.h:278
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
Definition layer_ids.h:340
@ LAYER_CURSOR
PCB cursor.
Definition layer_ids.h:281
@ LAYER_RATSNEST
Definition layer_ids.h:252
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
Definition layer_ids.h:344
@ LAYER_PAD_COPPER_END
Definition layer_ids.h:337
@ LAYER_ZONE_START
Virtual layers for stacking zones and tracks on a given copper layer.
Definition layer_ids.h:332
@ LAYER_FP_TEXT
Definition layer_ids.h:239
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
Definition layer_ids.h:259
@ LAYER_UI_END
Definition layer_ids.h:357
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition layer_ids.h:247
@ LAYER_VIA_COPPER_END
Definition layer_ids.h:341
@ LAYER_MARKER_SHADOWS
Shadows for DRC markers.
Definition layer_ids.h:304
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
Definition layer_ids.h:273
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
Definition layer_ids.h:262
@ LAYER_POINT_START
Virtual layers for points per board layer.
Definition layer_ids.h:352
@ LAYER_VIA_MICROVIA
Definition layer_ids.h:233
@ LAYER_SELECT_OVERLAY
Selected items overlay.
Definition layer_ids.h:279
@ LAYER_VIA_THROUGH
Draw blind/buried vias.
Definition layer_ids.h:235
@ LAYER_BITMAP_END
Definition layer_ids.h:349
@ LAYER_BITMAP_START
Virtual layers for background images per board layer.
Definition layer_ids.h:348
@ LAYER_DRC_ERROR
Layer for DRC markers with #SEVERITY_ERROR.
Definition layer_ids.h:276
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition layer_ids.h:232
@ LAYER_VIA_BBLIND
Draw micro vias.
Definition layer_ids.h:234
@ LAYER_PAD_HOLEWALLS
Definition layer_ids.h:296
#define CLEARANCE_LAYER_FOR(boardLayer)
Definition layer_ids.h:370
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition layer_ids.h:865
#define VIA_COPPER_LAYER_FOR(boardLayer)
Definition layer_ids.h:369
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ User_16
Definition layer_ids.h:139
@ In22_Cu
Definition layer_ids.h:87
@ In11_Cu
Definition layer_ids.h:76
@ User_29
Definition layer_ids.h:152
@ In29_Cu
Definition layer_ids.h:94
@ In30_Cu
Definition layer_ids.h:95
@ User_40
Definition layer_ids.h:163
@ User_15
Definition layer_ids.h:138
@ User_8
Definition layer_ids.h:131
@ F_CrtYd
Definition layer_ids.h:116
@ User_11
Definition layer_ids.h:134
@ User_25
Definition layer_ids.h:148
@ In17_Cu
Definition layer_ids.h:82
@ User_34
Definition layer_ids.h:157
@ User_45
Definition layer_ids.h:168
@ B_Adhes
Definition layer_ids.h:103
@ User_36
Definition layer_ids.h:159
@ Edge_Cuts
Definition layer_ids.h:112
@ Dwgs_User
Definition layer_ids.h:107
@ F_Paste
Definition layer_ids.h:104
@ In9_Cu
Definition layer_ids.h:74
@ Cmts_User
Definition layer_ids.h:108
@ User_6
Definition layer_ids.h:129
@ User_7
Definition layer_ids.h:130
@ In19_Cu
Definition layer_ids.h:84
@ User_19
Definition layer_ids.h:142
@ User_23
Definition layer_ids.h:146
@ In7_Cu
Definition layer_ids.h:72
@ In28_Cu
Definition layer_ids.h:93
@ In26_Cu
Definition layer_ids.h:91
@ F_Adhes
Definition layer_ids.h:102
@ User_41
Definition layer_ids.h:164
@ B_Mask
Definition layer_ids.h:98
@ B_Cu
Definition layer_ids.h:65
@ User_14
Definition layer_ids.h:137
@ User_39
Definition layer_ids.h:162
@ User_5
Definition layer_ids.h:128
@ User_20
Definition layer_ids.h:143
@ Eco1_User
Definition layer_ids.h:109
@ F_Mask
Definition layer_ids.h:97
@ In21_Cu
Definition layer_ids.h:86
@ User_42
Definition layer_ids.h:165
@ User_43
Definition layer_ids.h:166
@ In23_Cu
Definition layer_ids.h:88
@ B_Paste
Definition layer_ids.h:105
@ In15_Cu
Definition layer_ids.h:80
@ In2_Cu
Definition layer_ids.h:67
@ User_10
Definition layer_ids.h:133
@ User_9
Definition layer_ids.h:132
@ User_27
Definition layer_ids.h:150
@ User_28
Definition layer_ids.h:151
@ F_Fab
Definition layer_ids.h:119
@ In10_Cu
Definition layer_ids.h:75
@ Margin
Definition layer_ids.h:113
@ F_SilkS
Definition layer_ids.h:100
@ In4_Cu
Definition layer_ids.h:69
@ B_CrtYd
Definition layer_ids.h:115
@ Eco2_User
Definition layer_ids.h:110
@ In16_Cu
Definition layer_ids.h:81
@ In24_Cu
Definition layer_ids.h:89
@ In1_Cu
Definition layer_ids.h:66
@ User_35
Definition layer_ids.h:158
@ User_31
Definition layer_ids.h:154
@ User_3
Definition layer_ids.h:126
@ User_1
Definition layer_ids.h:124
@ User_12
Definition layer_ids.h:135
@ B_SilkS
Definition layer_ids.h:101
@ User_30
Definition layer_ids.h:153
@ User_37
Definition layer_ids.h:160
@ User_22
Definition layer_ids.h:145
@ User_38
Definition layer_ids.h:161
@ In13_Cu
Definition layer_ids.h:78
@ User_4
Definition layer_ids.h:127
@ In8_Cu
Definition layer_ids.h:73
@ User_21
Definition layer_ids.h:144
@ In14_Cu
Definition layer_ids.h:79
@ User_24
Definition layer_ids.h:147
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:171
@ User_13
Definition layer_ids.h:136
@ User_2
Definition layer_ids.h:125
@ In12_Cu
Definition layer_ids.h:77
@ User_17
Definition layer_ids.h:140
@ In27_Cu
Definition layer_ids.h:92
@ In6_Cu
Definition layer_ids.h:71
@ In5_Cu
Definition layer_ids.h:70
@ User_33
Definition layer_ids.h:156
@ User_26
Definition layer_ids.h:149
@ In3_Cu
Definition layer_ids.h:68
@ User_32
Definition layer_ids.h:155
@ In20_Cu
Definition layer_ids.h:85
@ User_18
Definition layer_ids.h:141
@ User_44
Definition layer_ids.h:167
@ F_Cu
Definition layer_ids.h:64
@ In18_Cu
Definition layer_ids.h:83
@ In25_Cu
Definition layer_ids.h:90
@ B_Fab
Definition layer_ids.h:118
#define ZONE_LAYER_FOR(boardLayer)
Definition layer_ids.h:367
#define PAD_COPPER_LAYER_FOR(boardLayer)
Definition layer_ids.h:368
This file contains miscellaneous commonly used macros and functions.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition definitions.h:38
@ TARGET_CACHED
Main rendering target (cached)
Definition definitions.h:37
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
Definition definitions.h:39
const int GAL_LAYER_ORDER[]
BOARD * GetBoard()
see class PGM_BASE
Class that computes missing connections on a PCB.
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:97
WX_VIEW_CONTROLS class definition.
#define ZOOM_MAX_LIMIT_PCBNEW
#define ZOOM_MIN_LIMIT_PCBNEW