39 PCB_DIFF_PAINTER( KIGFX::GAL* aGal, std::map<KIID, KIGFX::COLOR4D> aOverrides ) :
41 m_overrides( std::
move( aOverrides ) ),
42 m_dimmed( std::make_shared<std::set<KIID>>() )
48 std::shared_ptr<std::set<KIID>> DimmedSet()
const {
return m_dimmed; }
50 bool Draw(
const KIGFX::VIEW_ITEM* aItem,
int aLayer )
override
52 const EDA_ITEM* edaItem =
dynamic_cast<const EDA_ITEM*
>( aItem );
58 if( m_overrides.count( key ) == 0 )
60 if(
const BOARD_ITEM* boardItem =
dynamic_cast<const BOARD_ITEM*
>( aItem ) )
62 if(
const FOOTPRINT* fp = boardItem->GetParentFootprint() )
67 auto it = m_overrides.find( key );
69 if( it != m_overrides.end() && m_dimmed->count( key ) == 0 )
74 KIGFX::PCB_RENDER_SETTINGS* settings = GetSettings();
75 std::vector<std::pair<int, KIGFX::COLOR4D>> saved;
77 for(
int layer : colorSourceLayers( aLayer ) )
79 saved.emplace_back( layer, settings->
GetLayerColor( layer ) );
85 for(
const auto& [layer, color] : saved )
97 static std::vector<int> colorSourceLayers(
int aLayer )
124 std::map<KIID, KIGFX::COLOR4D> m_overrides;
125 std::shared_ptr<std::set<KIID>> m_dimmed;
136 std::vector<KIGFX::VIEW_ITEM*> items;
138 items.push_back( &aFootprint );
141 items.push_back( field );
144 items.push_back( item );
147 items.push_back(
pad );
150 items.push_back( zone );
158 std::vector<KIGFX::VIEW_ITEM*> items;
161 items.push_back( track );
164 items.push_back( zone );
167 items.push_back( item );
172 items.insert( items.end(), fpItems.begin(), fpItems.end() );
213 std::map<KIID, KIGFX::COLOR4D> aOverrides )
215 auto painter = std::make_unique<PCB_DIFF_PAINTER>( aGal, std::move( aOverrides ) );
223 const KIGFX::COLOR4D& aColor,
const std::map<KIID, KIGFX::COLOR4D>& aOverrides,
224 const std::vector<KIGFX::VIEW_ITEM*>& aExtraItems,
225 const std::map<KIID, KICAD_DIFF::CATEGORY>& aCategories )
227 auto painter = std::make_unique<PCB_DIFF_PAINTER>( aCanvas.
GetGAL(), aOverrides );
230 std::shared_ptr<std::set<KIID>> dimmed = painter->DimmedSet();
248 std::vector<KIGFX::VIEW_ITEM*> items;
253 items.insert( items.end(), refItems.begin(), refItems.end() );
259 items.insert( items.end(), compItems.begin(), compItems.end() );
262 items.insert( items.end(), aExtraItems.begin(), aExtraItems.end() );
269 std::map<KIGFX::VIEW_ITEM*, KICAD_DIFF::CATEGORY> itemCategories;
280 if( it != aCategories.end() )
281 itemCategories[viewItem] = it->second;
289 std::shared_ptr<const void> aOwner )
291 if( !aBefore && !aAfter )
298 std::map<KIID, KIGFX::COLOR4D> overrides;
299 std::vector<KIGFX::VIEW_ITEM*> items;
301 if( !aBefore || !aAfter )
304 FOOTPRINT* shown = aAfter ? aAfter : aBefore;
318 items.push_back(
const_cast<EDA_ITEM*
>( element.item ) );
334 auto holder = std::make_shared<BOARD>();
342 auto footprint = aSide.find( aName );
344 if( footprint == aSide.end() || !footprint->second )
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const ZONES & Zones() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const DRAWINGS & Drawings() const
virtual KIGFX::VIEW * GetView() const
Return a pointer to the KIGFX::VIEW instance used in the panel.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
A base class for most all the KiCad significant classes used in schematics and boards.
std::map< wxString, const FOOTPRINT * > FOOTPRINT_MAP
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D BLACK
Abstract interface for drawing on a 2D-surface.
Contains methods for drawing PCB-specific items.
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
PCB specific render settings.
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
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 SetAllLayerColors(const COLOR4D &aColor)
Change the color used to draw every layer.
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
void SetHighContrast(bool aEnabled)
Turns on/off high contrast display mode.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
An abstract base class for deriving all objects that can be added to a VIEW.
static const LSET & AllLayersMask()
double m_TrackOpacity
Opacity override for all tracks.
double m_FilledShapeOpacity
Opacity override for graphic shapes.
double m_ZoneOpacity
Opacity override for filled zone areas.
double m_ImageOpacity
Opacity override for user images.
double m_PadOpacity
Opacity override for SMD pads and PTHs.
double m_ViaOpacity
Opacity override for all types of via.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
ZONE_DISPLAY_MODE m_ZoneDisplayMode
Handle a list of polygons defining a copper zone.
@ NETNAMES_LAYER_ID_START
bool IsPadCopperLayer(int aLayer)
bool IsClearanceLayer(int aLayer)
@ LAYER_PAD_COPPER_START
Virtual layers for pad copper on a given copper layer.
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
@ LAYER_PCB_BACKGROUND
PCB background color.
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
@ 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_VIA_HOLES
Draw via holes (pad holes do not use this layer).
bool IsViaCopperLayer(int aLayer)
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
bool IsZoneFillLayer(int aLayer)
std::vector< KIGFX::VIEW_ITEM * > CollectBoardDiffContextItems(BOARD &aBoard)
std::vector< LIB_ELEMENT > DiffFootprintElements(const FOOTPRINT *aBefore, const FOOTPRINT *aAfter)
Compare the elements of two library footprints.
void ConfigureFpDiffCanvasContext(WIDGET_DIFF_CANVAS &aCanvas, FOOTPRINT *aBefore, FOOTPRINT *aAfter, std::shared_ptr< const void > aOwner)
Draw aAfter with its changes from aBefore marked. aOwner keeps both alive while they are shown.
void ConfigurePcbDiffCanvasContext(WIDGET_DIFF_CANVAS &aCanvas, BOARD *aReference, BOARD *aComparison, const KIGFX::COLOR4D &aColor, const std::map< KIID, KIGFX::COLOR4D > &aOverrides, const std::vector< KIGFX::VIEW_ITEM * > &aExtraItems, const std::map< KIID, KICAD_DIFF::CATEGORY > &aCategories)
std::unique_ptr< KIGFX::PAINTER > MakePcbDiffContextPainter(KIGFX::GAL *aGal, const KIGFX::COLOR4D &aColor, std::map< KIID, KIGFX::COLOR4D > aOverrides)
KIID PcbDiffItemId(const EDA_ITEM &aItem)
Fields match by parent footprint and untranslated name, including after a library refresh.
void ConfigurePcbDiffContextRenderSettings(KIGFX::PCB_RENDER_SETTINGS &aSettings, const KIGFX::COLOR4D &aColor)
std::vector< KIGFX::VIEW_ITEM * > CollectFootprintDiffContextItems(FOOTPRINT &aFootprint)
void ShowFootprintPair(WIDGET_DIFF_CANVAS &aCanvas, const FP_LIB_DIFFER::FOOTPRINT_MAP &aBefore, const FP_LIB_DIFFER::FOOTPRINT_MAP &aAfter, const wxString &aName)
Draw the footprint aName as it is in aBefore and aAfter.
void ApplyPcbGalLayerDeps(KIGFX::VIEW *aView)
Make pcbnew's derived layers (pad copper, zones, holes, netnames) follow their board layer's visibili...
void ApplyPcbGalLayerOrder(KIGFX::VIEW *aView)
Apply pcbnew's canonical GAL layer order (copper and zones below silk, fab and courtyard) to any view...
Diff colors with defaults for light backgrounds.
KIGFX::COLOR4D reference
Default color for source-document context geometry.
const KIGFX::COLOR4D & ForKind(KICAD_DIFF::CHANGE_KIND aKind) const
Color of an added, removed or modified element.
One changed element of a library item, such as a pin, pad, field or graphic.
wxString result
Test unit parsing edge cases and error handling.