58#include <fmt/format.h>
60using namespace std::placeholders;
232 const wxPoint& aPosition,
const wxSize& aSize,
242 frameType = frame->GetFrameType();
244 m_painter = std::make_unique<KIGFX::PCB_PAINTER>(
m_gal, frameType );
288 std::vector<KIGFX::VIEW_ITEM*> viewItems;
297 viewItems.push_back( item );
301 static_cast<FOOTPRINT*
>( item )->RunOnChildren(
305 viewItems.push_back( child );
311 m_view->AddBatch( viewItems );
342 wxCHECK_RET( cs, wxT(
"null COLOR_SETTINGS" ) );
355 std::vector<KIGFX::GRID_SOURCE> sources;
357 BOARD* board =
nullptr;
367 m_gal->SetGridSources( std::move( sources ) );
389 wxASSERT(
grid->GetAssignedPriority() > 0 );
400 src.
color = gridItemColor;
403 sources.push_back( src );
406 m_gal->SetGridSources( std::move( sources ) );
447 for(
int i : layers )
458 else if( aLayer ==
F_Cu )
464 m_view->UpdateAllLayersColor();
472 m_view->SetTopLayer( aLayer );
475 const std::vector<int> layers = {
483 for(
auto layer : layers )
484 m_view->SetTopLayer( layer );
490 const std::vector<int> frontLayers = {
495 const std::vector<int> backLayers = {
500 const std::vector<int>* extraLayers =
nullptr;
504 extraLayers = &frontLayers;
506 extraLayers = &backLayers;
510 for(
auto layer : *extraLayers )
512 m_view->SetTopLayer( layer );
555 m_view->EnableTopLayer(
true );
556 m_view->UpdateAllLayersOrder();
577 m_view->SetLayerVisible( i,
true );
580 m_view->SetLayerVisible( i,
true );
583 m_view->SetLayerVisible( i,
true );
586 m_view->SetLayerVisible( i,
true );
591 m_view->SetLayerVisible( i,
true );
594 m_view->SetLayerVisible( i,
false );
597 m_view->SetLayerVisible( i,
true );
600 m_view->SetLayerVisible( i,
true );
603 m_view->SetLayerVisible( i,
true );
620 std::vector<MSG_PANEL_ITEM>& aList )
625 int trackSegmentCount = 0;
626 std::set<int> netCodes;
636 if( item->GetNetCode() > 0 )
637 netCodes.insert( item->GetNetCode() );
642 for(
PAD*
pad : footprint->Pads() )
646 if(
pad->GetNetCode() > 0 )
647 netCodes.insert(
pad->GetNetCode() );
651 aList.emplace_back(
_(
"Pads" ), fmt::format(
"{}", padCount ) );
652 aList.emplace_back(
_(
"Vias" ), fmt::format(
"{}", viaCount ) );
653 aList.emplace_back(
_(
"Track Segments" ), fmt::format(
"{}", trackSegmentCount ) );
654 aList.emplace_back(
_(
"Nets" ), fmt::format(
"{}", (
int) netCodes.size() ) );
655 aList.emplace_back(
_(
"Unrouted" ), fmt::format(
"{}", unconnected ) );
671 catch(
const std::runtime_error& e )
700 for(
int i = 0; (unsigned) i <
sizeof(
GAL_LAYER_ORDER ) /
sizeof( int ); ++i )
737 m_gal->SetWorldUnitLength( 1e-9 / 0.0254 );
764 m_view->SetLayerTarget( i, target );
771 for(
int i = 0; (unsigned) i <
sizeof(
GAL_LAYER_ORDER ) /
sizeof( int ); ++i )
800 m_view->SetLayerDisplayOnly( layer );
855 m_view->SetLayerDisplayOnly( i );
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 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.
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.
@ 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.
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
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)
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 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
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
virtual PCB_LAYER_ID GetActiveLayer() const
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.
virtual ~PCB_DRAW_PANEL_GAL()
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Sets (or updates) drawing-sheet used by the draw panel.
void setDefaultLayerDeps()
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.
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.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
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
@ 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 #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_CURSOR
PCB cursor.
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
@ 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 #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.
@ 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)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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