KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema/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 <sch_item.h>
18#include <sch_screen.h>
19#include <sch_sheet_path.h>
20#include <sch_symbol.h>
21#include <schematic.h>
23
24
25using namespace KICAD_DIFF;
26
27
28BOOST_AUTO_TEST_SUITE( SchDiffCanvasContext )
29
30
31BOOST_AUTO_TEST_CASE( ForcedPainterColorIgnoresSchematicLayerColors )
32{
33 const KIGFX::COLOR4D changeColor( 0.38, 0.38, 0.38, 0.42 );
34 SCH_RENDER_SETTINGS settings;
35 ConfigureSchDiffContextRenderSettings( settings, changeColor );
36
37 // Unchanged schematic renders a single neutral grey, so real per-layer colors
38 // are ignored: different layers resolve to the same colour.
39 KIGFX::COLOR4D device = settings.GetColor( nullptr, LAYER_DEVICE );
40 KIGFX::COLOR4D wire = settings.GetColor( nullptr, LAYER_WIRE );
41
42 BOOST_CHECK_CLOSE( device.r, wire.r, 0.001 );
43 BOOST_CHECK_CLOSE( device.g, wire.g, 0.001 );
44 BOOST_CHECK_CLOSE( device.b, wire.b, 0.001 );
45
46 // The forced change colour is applied to highlighted (changed) items.
47 KIGFX::COLOR4D brightened = settings.GetLayerColor( LAYER_BRIGHTENED );
48
49 BOOST_CHECK_CLOSE( brightened.r, changeColor.r, 0.001 );
50 BOOST_CHECK_CLOSE( brightened.g, changeColor.g, 0.001 );
51 BOOST_CHECK_CLOSE( brightened.b, changeColor.b, 0.001 );
52 BOOST_CHECK_CLOSE( brightened.a, changeColor.a, 0.001 );
53}
54
55
56BOOST_AUTO_TEST_CASE( CollectorIncludesActualSchematicItems )
57{
58 SETTINGS_MANAGER settings;
59 std::unique_ptr<SCHEMATIC> schematic;
60 KI_TEST::LoadSchematic( settings, "issue18606/issue18606", schematic );
61 BOOST_REQUIRE( schematic );
62
63 // The fixture keeps its symbols on a sub-sheet, so collect from every screen.
64 SCH_SCREENS screens( &schematic->Root() );
65 bool foundSymbol = false;
66
67 for( SCH_SCREEN* screen = screens.GetFirst(); screen && !foundSymbol; screen = screens.GetNext() )
68 {
69 for( KIGFX::VIEW_ITEM* item : CollectSchematicDiffContextItems( *schematic, screen ) )
70 {
71 if( dynamic_cast<SCH_SYMBOL*>( item ) )
72 {
73 foundSymbol = true;
74 break;
75 }
76 }
77 }
78
79 BOOST_CHECK( foundSymbol );
80}
81
82
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
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
virtual COLOR4D GetColor(const KIGFX::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...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:746
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Schematic symbol object.
Definition sch_symbol.h:69
BOOST_AUTO_TEST_CASE(ForcedPainterColorIgnoresSchematicLayerColors)
@ LAYER_DEVICE
Definition layer_ids.h:464
@ LAYER_BRIGHTENED
Definition layer_ids.h:489
@ LAYER_WIRE
Definition layer_ids.h:450
void ConfigureSchDiffContextRenderSettings(SCH_RENDER_SETTINGS &aSettings, const KIGFX::COLOR4D &aColor)
std::vector< KIGFX::VIEW_ITEM * > CollectSchematicDiffContextItems(SCHEMATIC &aSchematic, SCH_SCREEN *aScreen)
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()