KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pcb_render_settings.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 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
24
26#include <pcb_painter.h>
27#include <pcb_point.h>
28#include <layer_ids.h>
30
32{
33public:
36
38 {
39 m_colorSettings.SetColor( LAYER_POINTS, KIGFX::COLOR4D( 1.0, 0.0, 1.0, 1.0 ) );
40
41 for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
42 m_colorSettings.SetColor( i, KIGFX::COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
43
44 m_settings.LoadColors( &m_colorSettings );
45 }
46};
47
48
49BOOST_FIXTURE_TEST_SUITE( PcbRenderSettings, TEST_PCB_RENDER_SETTINGS_FIXTURE )
50
51
52
60BOOST_AUTO_TEST_CASE( PointLayerColorIsVisible )
61{
62 PCB_POINT point( nullptr );
63 point.SetLayer( F_SilkS );
64
65 int pointLayer = POINT_LAYER_FOR( F_SilkS );
66
67 KIGFX::COLOR4D color = m_settings.GetColor( &point, pointLayer );
68
69 BOOST_CHECK_MESSAGE( color.a > 0.0,
70 "Color for POINT layer should not be transparent (alpha was "
71 + std::to_string( color.a ) + ")" );
72
73 BOOST_CHECK_MESSAGE( color == m_colorSettings.GetColor( LAYER_POINTS ),
74 "POINT layer color should match LAYER_POINTS color" );
75}
76
77
81BOOST_AUTO_TEST_CASE( AllPointLayersMapToLayerPoints )
82{
83 KIGFX::COLOR4D expectedColor = m_colorSettings.GetColor( LAYER_POINTS );
84
85 std::vector<PCB_LAYER_ID> testLayers = { F_Cu, B_Cu, F_SilkS, B_SilkS, Edge_Cuts, User_1 };
86
87 for( PCB_LAYER_ID boardLayer : testLayers )
88 {
89 PCB_POINT point( nullptr );
90 point.SetLayer( boardLayer );
91
92 int pointLayer = POINT_LAYER_FOR( boardLayer );
93 KIGFX::COLOR4D color = m_settings.GetColor( &point, pointLayer );
94
95 BOOST_CHECK_MESSAGE( color == expectedColor,
96 "POINT layer for " + std::to_string( boardLayer )
97 + " should have LAYER_POINTS color" );
98 }
99}
100
101
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:313
Color settings are a bit different than most of the settings objects in that there can be more than o...
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
double a
Alpha component.
Definition color4d.h:392
PCB specific render settings.
Definition pcb_painter.h:78
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Definition pcb_point.h:39
#define POINT_LAYER_FOR(boardLayer)
Definition layer_ids.h:370
@ LAYER_POINTS
PCB reference/manual snap points visibility.
Definition layer_ids.h:317
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ Edge_Cuts
Definition layer_ids.h:108
@ B_Cu
Definition layer_ids.h:61
@ F_SilkS
Definition layer_ids.h:96
@ User_1
Definition layer_ids.h:120
@ B_SilkS
Definition layer_ids.h:97
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:167
@ F_Cu
Definition layer_ids.h:60
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(PointLayerColorIsVisible)
Test that PCB_RENDER_SETTINGS::GetColor returns a visible color for POINT layers.
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")