KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_active_layer_update.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
20// Re-caching every remove-unconnected pad on each active-layer change stalled the start of a track
21// drag on dense boards. activeLayerUpdateFlags() narrows that, but only with high contrast off.
22
24
25#include <board.h>
26#include <footprint.h>
27#include <pad.h>
28#include <pcb_shape.h>
29#include <pcb_edit_frame.h>
30#include <netinfo.h>
31#include <view/view_item.h>
33
34
35BOOST_AUTO_TEST_SUITE( ActiveLayerUpdate )
36
37
38BOOST_AUTO_TEST_CASE( OnlyFlashChangedPadsUpdateWithoutHighContrast )
39{
40 BOARD board;
42
43 auto footprint = std::make_unique<FOOTPRINT>( &board );
44 auto net = new NETINFO_ITEM( &board, "P1", 1 );
45 board.Add( net );
46
47 // PTH pad that flashes on the outer layers but not on an unconnected inner layer.
48 PAD* pad = new PAD( footprint.get() );
49 pad->SetAttribute( PAD_ATTRIB::PTH );
50 pad->SetLayerSet( LSET::AllCuMask() );
51 pad->SetSize( PADSTACK::ALL_LAYERS, VECTOR2I( pcbIUScale.mmToIU( 1.0 ), pcbIUScale.mmToIU( 1.0 ) ) );
52 pad->SetDrillSize( VECTOR2I( pcbIUScale.mmToIU( 0.5 ), pcbIUScale.mmToIU( 0.5 ) ) );
54 pad->SetNet( net );
55 footprint->Add( pad );
56 board.Add( footprint.release() );
57 board.BuildConnectivity();
58
59 BOOST_REQUIRE( pad->FlashLayer( F_Cu ) );
60 BOOST_REQUIRE( pad->FlashLayer( B_Cu ) );
61 BOOST_REQUIRE( !pad->FlashLayer( In1_Cu ) );
62
63 // Same flashing on both layers: nothing to re-cache.
67
70 KIGFX::ALL );
71
72 // High contrast also dims by active layer, so the redraw is kept even when flashing is unchanged.
75 KIGFX::ALL );
76
77 PCB_SHAPE shape( &board, SHAPE_T::RECTANGLE );
81}
82
83
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
@ FPHOLDER
Definition board.h:364
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ DIMMED
Inactive layers are dimmed (old high-contrast mode)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1295
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition board.h:384
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition board.cpp:201
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:595
Handle the data for a net.
Definition netinfo.h:46
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:177
Definition pad.h:61
static int activeLayerUpdateFlags(const BOARD_ITEM *aItem, PCB_LAYER_ID aOldLayer, PCB_LAYER_ID aNewLayer, HIGH_CONTRAST_MODE aContrastMode)
View update flags an item needs when the active layer changes. Static for testing.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:47
@ B_Cu
Definition layer_ids.h:61
@ In1_Cu
Definition layer_ids.h:62
@ F_Cu
Definition layer_ids.h:60
@ NONE
No updates are required.
Definition view_item.h:48
@ ALL
All except INITIAL_ADD.
Definition view_item.h:55
@ PTH
Plated through hole pad.
Definition padstack.h:98
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683