KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew/test_diff_canvas_context.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 */
11
14
16
17#include <board.h>
18#include <footprint.h>
19#include <pad.h>
21
22
23using namespace KICAD_DIFF;
24
25
26BOOST_AUTO_TEST_SUITE( PcbDiffCanvasContext )
27
28
29BOOST_AUTO_TEST_CASE( ForcedPainterColorIgnoresPcbLayerColors )
30{
31 const KIGFX::COLOR4D changeColor( 0.38, 0.38, 0.38, 0.42 );
33 ConfigurePcbDiffContextRenderSettings( settings, changeColor );
34
35 // Unchanged board renders a single neutral grey, so real per-layer colors are
36 // ignored: every copper layer resolves to the same colour.
37 KIGFX::COLOR4D fcu = settings.GetColor( static_cast<const BOARD_ITEM*>( nullptr ), F_Cu );
38 KIGFX::COLOR4D bcu = settings.GetColor( static_cast<const BOARD_ITEM*>( nullptr ), B_Cu );
39
40 BOOST_CHECK_CLOSE( fcu.r, bcu.r, 0.001 );
41 BOOST_CHECK_CLOSE( fcu.g, bcu.g, 0.001 );
42 BOOST_CHECK_CLOSE( fcu.b, bcu.b, 0.001 );
43
44 // The forced change colour is applied to highlighted (changed) items.
45 KIGFX::COLOR4D brightened = settings.GetLayerColor( LAYER_BRIGHTENED );
46
47 BOOST_CHECK_CLOSE( brightened.r, changeColor.r, 0.001 );
48 BOOST_CHECK_CLOSE( brightened.g, changeColor.g, 0.001 );
49 BOOST_CHECK_CLOSE( brightened.b, changeColor.b, 0.001 );
50 BOOST_CHECK_CLOSE( brightened.a, changeColor.a, 0.001 );
51}
52
53
54BOOST_AUTO_TEST_CASE( CollectorIncludesFootprintChildren )
55{
56 SETTINGS_MANAGER settings;
57 std::unique_ptr<BOARD> board;
58 KI_TEST::LoadBoard( settings, "complex_hierarchy", board );
59 BOOST_REQUIRE( board );
60
61 std::vector<KIGFX::VIEW_ITEM*> items = CollectBoardDiffContextItems( *board );
62
63 bool foundPad = false;
64
65 for( KIGFX::VIEW_ITEM* item : items )
66 {
67 if( dynamic_cast<PAD*>( item ) )
68 {
69 foundPad = true;
70 break;
71 }
72 }
73
74 BOOST_CHECK( foundPad );
75}
76
77
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:80
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
double r
Red component.
Definition color4d.h:389
double g
Green component.
Definition color4d.h:390
double a
Alpha component.
Definition color4d.h:392
double b
Blue component.
Definition color4d.h:391
PCB specific render settings.
Definition pcb_painter.h:78
COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:82
Definition pad.h:61
@ LAYER_BRIGHTENED
Definition layer_ids.h:489
@ B_Cu
Definition layer_ids.h:61
@ F_Cu
Definition layer_ids.h:60
std::vector< KIGFX::VIEW_ITEM * > CollectBoardDiffContextItems(BOARD &aBoard)
void ConfigurePcbDiffContextRenderSettings(KIGFX::PCB_RENDER_SETTINGS &aSettings, const KIGFX::COLOR4D &aColor)
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
BOOST_AUTO_TEST_CASE(ForcedPainterColorIgnoresPcbLayerColors)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()