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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
28
30#include <pcb_painter.h>
31#include <pcb_point.h>
32#include <layer_ids.h>
34
36{
37public:
40
42 {
43 m_colorSettings.SetColor( LAYER_POINTS, KIGFX::COLOR4D( 1.0, 0.0, 1.0, 1.0 ) );
44
45 for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
46 m_colorSettings.SetColor( i, KIGFX::COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
47
48 m_settings.LoadColors( &m_colorSettings );
49 }
50};
51
52
53BOOST_FIXTURE_TEST_SUITE( PcbRenderSettings, TEST_PCB_RENDER_SETTINGS_FIXTURE )
54
55
56
64BOOST_AUTO_TEST_CASE( PointLayerColorIsVisible )
65{
66 PCB_POINT point( nullptr );
67 point.SetLayer( F_SilkS );
68
69 int pointLayer = POINT_LAYER_FOR( F_SilkS );
70
71 KIGFX::COLOR4D color = m_settings.GetColor( &point, pointLayer );
72
73 BOOST_CHECK_MESSAGE( color.a > 0.0,
74 "Color for POINT layer should not be transparent (alpha was "
75 + std::to_string( color.a ) + ")" );
76
77 BOOST_CHECK_MESSAGE( color == m_colorSettings.GetColor( LAYER_POINTS ),
78 "POINT layer color should match LAYER_POINTS color" );
79}
80
81
85BOOST_AUTO_TEST_CASE( AllPointLayersMapToLayerPoints )
86{
87 KIGFX::COLOR4D expectedColor = m_colorSettings.GetColor( LAYER_POINTS );
88
89 std::vector<PCB_LAYER_ID> testLayers = { F_Cu, B_Cu, F_SilkS, B_SilkS, Edge_Cuts, User_1 };
90
91 for( PCB_LAYER_ID boardLayer : testLayers )
92 {
93 PCB_POINT point( nullptr );
94 point.SetLayer( boardLayer );
95
96 int pointLayer = POINT_LAYER_FOR( boardLayer );
97 KIGFX::COLOR4D color = m_settings.GetColor( &point, pointLayer );
98
99 BOOST_CHECK_MESSAGE( color == expectedColor,
100 "POINT layer for " + std::to_string( boardLayer )
101 + " should have LAYER_POINTS color" );
102 }
103}
104
105
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:284
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:105
double a
Alpha component.
Definition color4d.h:396
PCB specific render settings.
Definition pcb_painter.h:82
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:43
#define POINT_LAYER_FOR(boardLayer)
Definition layer_ids.h:372
@ LAYER_POINTS
PCB reference/manual snap points visibility.
Definition layer_ids.h:321
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ Edge_Cuts
Definition layer_ids.h:112
@ B_Cu
Definition layer_ids.h:65
@ F_SilkS
Definition layer_ids.h:100
@ User_1
Definition layer_ids.h:124
@ B_SilkS
Definition layer_ids.h:101
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:171
@ F_Cu
Definition layer_ids.h:64
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.