58#include <fmt/format.h>
60using namespace std::placeholders;
234 const wxPoint& aPosition,
const wxSize& aSize,
244 frameType = frame->GetFrameType();
246 m_painter = std::make_unique<KIGFX::PCB_PAINTER>(
m_gal, frameType );
290 std::vector<KIGFX::VIEW_ITEM*> viewItems;
299 viewItems.push_back( item );
303 static_cast<FOOTPRINT*
>( item )->RunOnChildren(
307 viewItems.push_back( child );
313 m_view->AddBatch( viewItems );
328 if(
m_gal->HasRetainedScene() )
336 m_ratsnest = std::make_unique<RATSNEST_VIEW_ITEM>( aConnectivity );
370 wxCHECK_RET( cs, wxT(
"null COLOR_SETTINGS" ) );
383 std::vector<KIGFX::GRID_SOURCE> sources;
385 BOARD* board =
nullptr;
395 m_gal->SetGridSources( std::move( sources ) );
417 wxASSERT(
grid->GetAssignedPriority() > 0 );
428 src.
color = gridItemColor;
431 sources.push_back( src );
434 m_gal->SetGridSources( std::move( sources ) );
488 for(
int i : layers )
499 else if( aLayer ==
F_Cu )
512 if( aOnlyLayerChanged && pcbSettings->HasCanvasFadedLayers() && !hidden && !
m_highContrastHidden )
515 [pcbSettings](
int aViewLayer )
517 return !pcbSettings->IsCanvasFadedLayer( aViewLayer );
522 m_view->UpdateAllLayersColorAndVisibility();
526 m_view->UpdateAllLayersColor();
538 m_view->SetTopLayer( aLayer );
541 const std::vector<int> layers = {
552 for(
auto layer : layers )
553 m_view->SetTopLayer( layer );
559 const std::vector<int> frontLayers = {
564 const std::vector<int> backLayers = {
569 const std::vector<int>* extraLayers =
nullptr;
573 extraLayers = &frontLayers;
575 extraLayers = &backLayers;
579 for(
auto layer : *extraLayers )
581 m_view->SetTopLayer( layer );
624 m_view->EnableTopLayer(
true );
625 m_view->UpdateAllLayersOrder();
635 if( frame && frame->
GetCanvas() ==
this )
708 std::vector<MSG_PANEL_ITEM>& aList )
713 int trackSegmentCount = 0;
714 std::set<int> netCodes;
724 if( item->GetNetCode() > 0 )
725 netCodes.insert( item->GetNetCode() );
730 for(
PAD*
pad : footprint->Pads() )
734 if(
pad->GetNetCode() > 0 )
735 netCodes.insert(
pad->GetNetCode() );
739 aList.emplace_back(
_(
"Pads" ), fmt::format(
"{}", padCount ) );
740 aList.emplace_back(
_(
"Vias" ), fmt::format(
"{}", viaCount ) );
741 aList.emplace_back(
_(
"Track Segments" ), fmt::format(
"{}", trackSegmentCount ) );
742 aList.emplace_back(
_(
"Nets" ), fmt::format(
"{}", (
int) netCodes.size() ) );
743 aList.emplace_back(
_(
"Unrouted" ), fmt::format(
"{}", unconnected ) );
771 for(
int i = 0; (unsigned) i <
sizeof(
GAL_LAYER_ORDER ) /
sizeof( int ); ++i )
808 m_gal->SetWorldUnitLength( 1e-9 / 0.0254 );
813 std::shared_ptr<CONNECTIVITY_DATA> connectivity =
m_ratsnest->GetConnectivity();
857 m_view->SetLayerTarget( i, target );
864 for(
int i = 0; (unsigned) i <
sizeof(
GAL_LAYER_ORDER ) /
sizeof( int ); ++i )
893 m_view->SetLayerDisplayOnly( layer );
939 const bool cachedRatsnest =
m_gal &&
m_gal->HasRetainedScene();
968 m_view->SetLayerDisplayOnly( i );
978 std::bitset<MAX_LAYERS_FOR_VIEW> layers;
984 for(
int viewLayer : { layer,
static_cast<int>(
ZONE_LAYER_FOR( layer ) ),
989 if(
m_view->IsCached( viewLayer ) )
990 layers.set( viewLayer );
@ HIDDEN
Inactive layers are hidden.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Information pertinent to a Pcbnew printed circuit board.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
PCB_BOARD_OUTLINE * BoardOutline()
void UpdateBoardOutline()
const FOOTPRINTS & Footprints() const
const BOARD_ITEM_SET GetItemSet()
Collect every owned item (tracks, zones, generators, footprints, drawings, markers,...
const TRACKS & Tracks() const
const wxString & GetFileName() const
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
const DRAWINGS & Drawings() const
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 aVisibleOnly) const
The base frame for deriving all KiCad main window classes.
The base class for create windows for drawing purpose.
virtual void OnShow()
Called when the window is shown for the first time.
std::unique_ptr< KIGFX::PAINTER > m_painter
Contains information about how to draw items using GAL.
bool IsDialogPreview() const
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.
static bool IsAccelerated(GAL_TYPE aCanvasType)
True for a canvas drawn on the GPU, which keeps cached layers between frames.
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.
KICAD_T Type() const
Returns the type of object.
A color representation with 4 components: red, green, blue, alpha.
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.
void LoadColors(const COLOR_SETTINGS *aSettings) override
void SetCanvasFadedLayers(const std::bitset< MAX_LAYERS_FOR_VIEW > &aLayers)
Let the canvas fade these VIEW layers as a whole for high contrast, see GAL::SetSceneLayerDim().
HIGH_CONTRAST_MODE m_ContrastModeDisplay
bool m_ForceShowFieldsWhenFPSelected
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)
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)
bool GetHighContrast() const
void SetLayerIsHighContrast(int aLayerId, bool aEnabled=true)
Set the specified layer as high-contrast.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
static constexpr int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
int GetLayerOrder(int aLayer) const
Return rendering order of a particular layer.
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
void SetLayerOrder(int aLayer, int aRenderingOrder, bool aAutoSort=true)
Set rendering order of a particular layer.
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
void SortOrderedLayers()
Sorts m_orderedLayers after layer rendering order has changed.
An implementation of class VIEW_CONTROLS for wxWidgets library.
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
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual PCB_LAYER_ID GetActiveLayer() const
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
void ChangeHighContrastLayer(PCB_LAYER_ID aLayer)
Follow an active layer change when nothing else that colours items has changed.
void UpdateColors()
Update the color settings in the painter and GAL.
void updateCanvasFadedLayers()
Let a retained scene apply the high contrast dim of cached layers whose dim does not depend on the it...
std::unique_ptr< RATSNEST_VIEW_ITEM > m_localRatsnest
Moving items' part, when split off.
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
Move the selected layer to the top, so it is displayed above all others.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
std::unique_ptr< RATSNEST_VIEW_ITEM > m_ratsnest
Ratsnest view item.
void applyHighContrastLayer(PCB_LAYER_ID aLayer, bool aOnlyLayerChanged)
Make aLayer the high contrast layer.
virtual ~PCB_DRAW_PANEL_GAL()
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Set or update drawing-sheet used by the draw panel.
void setDefaultLayerDeps()
Set rendering targets & dependencies for layers.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the KIGFX::VIEW instance used in the panel.
void beforeRedraw() override
Hook for subclasses to update view items whose inputs nothing else tracks.
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.
bool m_highContrastShown
High contrast was on at the last recolour, so the next one may bring items back.
void setDefaultLayerOrder()
Reassign layer order to the initial settings.
PCB_DRAW_PANEL_GAL(wxWindow *aParentWindow, wxWindowID aWindowId, const wxPoint &aPosition, const wxSize &aSize, KIGFX::GAL_DISPLAY_OPTIONS &aOptions, GAL_TYPE aGalType=GAL_TYPE_MODERN)
bool m_highContrastHidden
High contrast hid inactive layers at the last recolour, which the canvas cannot fade away.
virtual void SetHighContrastLayer(int aLayer) override
Take care of display settings for the given layer to be displayed in high contrast mode.
void addRatsnest(std::shared_ptr< CONNECTIVITY_DATA > aConnectivity)
Add the ratsnest items the current canvas needs.
std::unique_ptr< DS_PROXY_VIEW_ITEM > m_drawingSheet
Currently used drawing-sheet.
bool SwitchBackend(GAL_TYPE aGalType) override
Switch method of rendering graphics.
void RedrawRatsnest()
Force refresh of the ratsnest visual representation.
void prepareGridSources() override
Push a GRID_SOURCE for every PCB_GRIDITEM on the board to the GAL.
A progress reporter interface for use in multi-threaded environments.
static constexpr int LOCAL_LAYER
The local part is drawn on a UI layer, which every canvas keeps on its overlay.
This file is part of the common library.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
@ FRAME_FOOTPRINT_PREVIEW
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
@ LAYER_PAD_FR_NETNAMES
Additional netnames layers (not associated with a PCB layer).
@ NETNAMES_LAYER_ID_START
#define BITMAP_LAYER_FOR(boardLayer)
Macros for getting the extra layers for a given board layer.
#define NETNAMES_LAYER_INDEX(layer)
Macro for obtaining netname layer for a given PCB layer.
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
#define POINT_LAYER_FOR(boardLayer)
bool IsNonCopperLayer(int aLayerId)
Test whether a layer is a non copper layer.
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
@ LAYER_DRILL_SYMBOL_START
Drill symbols, one channel per board layer.
@ LAYER_POINTS
PCB reference/manual snap points visibility.
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
@ LAYER_PAD_COPPER_START
Virtual layers for pad copper on a given copper layer.
@ LAYER_CONFLICTS_SHADOW
Shadow layer for items flagged conflicting.
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
@ LAYER_VIA_STITCHING
Outline of via stitching generators.
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
@ LAYER_BOARD_OUTLINE_AREA
PCB board outline.
@ LAYER_DRC_EXCLUSION
Layer for DRC markers which have been individually excluded.
@ LAYER_DRC_HIGHLIGHTED
Color for highlighted DRC markers.
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
@ LAYER_DRC_WARNING
Layer for DRC markers with RPT_SEVERITY_WARNING.
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
@ LAYER_GP_OVERLAY
General purpose overlay.
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
@ LAYER_CONSTRAINT_SHADOW
Shadow layer for items bound to a constraint.
@ LAYER_ROUTER_PREVIEW_COLLISION
Router preview collision marker, drawn above all board items.
@ LAYER_CURSOR
PCB cursor.
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
@ LAYER_ROUTER_PREVIEW_SHADOW
Router preview clearance shadow, drawn behind board copper.
@ LAYER_ZONE_START
Virtual layers for stacking zones and tracks on a given copper layer.
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
@ LAYER_VIA_BURIED
Draw blind vias.
@ LAYER_MARKER_SHADOWS
Shadows for DRC markers.
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
@ LAYER_VIA_BLIND
Draw micro vias.
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
@ LAYER_POINT_START
Virtual layers for points per board layer.
@ LAYER_SELECT_OVERLAY
Selected items overlay.
@ LAYER_VIA_THROUGH
Draw buried vias.
@ LAYER_SUBGRIDS
Routing/placement subgrids (PCB_GRID_ITEM) visibility and color.
@ LAYER_BITMAP_START
Virtual layers for background images per board layer.
@ LAYER_DRC_ERROR
Layer for DRC markers with RPT_SEVERITY_ERROR.
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
#define CLEARANCE_LAYER_FOR(boardLayer)
#define DRILL_SYMBOL_LAYER_FOR(boardLayer)
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
#define VIA_COPPER_LAYER_FOR(boardLayer)
PCB_LAYER_ID
A quick note on layer IDs:
#define ZONE_LAYER_FOR(boardLayer)
#define PAD_COPPER_LAYER_FOR(boardLayer)
This file contains miscellaneous commonly used macros and functions.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
@ TARGET_CACHED
Main rendering target (cached)
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
const int GAL_LAYER_ORDER[]
void ApplyPcbGalLayerOrder(KIGFX::VIEW *aView)
Apply pcbnew's canonical GAL layer order (copper and zones below silk, fab and courtyard) to any view...
void ApplyPcbGalLayerOrder(KIGFX::VIEW *aView)
Apply pcbnew's canonical GAL layer order (copper and zones below silk, fab and courtyard) to any view...
Class that computes missing connections on a PCB.
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
Geometry of a regular grid (cartesian or polar) and the math operations for snapping and coverage tes...
VECTOR2D pitch
Cartesian: (dx, dy); polar: (dr, dPhi rad).
Render-time projection of a grid: GRID_GEOMETRY (kind/origin/pitch/orientation/extent) plus rendering...
bool snapCursor
Participate in the cursor snap (GAL::GetGridPoint).
unsigned tick
Major-tick interval (0 = inherit default).
bool highlighted
Render with edit-mode emphasis (selected grid).
bool m_ForceShowFieldsWhenFPSelected
@ PCB_CONSTRAINT_T
a geometric constraint between board items
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_GRID_ITEM_T
a subgrid placed on a board
WX_VIEW_CONTROLS class definition.
#define ZOOM_MAX_LIMIT_PCBNEW
#define ZOOM_MIN_LIMIT_PCBNEW