KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue24901.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
21
22#include <board.h>
23#include <footprint.h>
24#include <pcb_field.h>
25#include <pcb_group.h>
26#include <pcb_shape.h>
28
29// Regression test for https://gitlab.com/kicad/code/kicad/-/issues/24901
30//
31// A footprint whose reference field carried (locked yes) in the file could not be moved even
32// though every piece of footprint-level UI reported it as unlocked. Locked items inside a
33// footprint move rigidly with it, so they must not pin the footprint. Locked group members
34// still pin their group (issue 6841).
35
36BOOST_AUTO_TEST_SUITE( Issue24901 )
37
38
39BOOST_AUTO_TEST_CASE( LockedFieldDoesNotPinFootprint )
40{
41 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
42
43 FOOTPRINT* footprint = new FOOTPRINT( board.get() );
44 board->Add( footprint );
45
46 footprint->Reference().SetLocked( true );
47
48 BOOST_CHECK( !footprint->IsLocked() );
49 BOOST_CHECK( footprint->Reference().IsLocked() );
50 BOOST_CHECK( !PCB_SELECTION_TOOL::HasLockedDescendant( footprint ) );
51}
52
53
54BOOST_AUTO_TEST_CASE( LockedGraphicDoesNotPinFootprint )
55{
56 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
57
58 FOOTPRINT* footprint = new FOOTPRINT( board.get() );
59 board->Add( footprint );
60
61 PCB_SHAPE* shape = new PCB_SHAPE( footprint, SHAPE_T::SEGMENT );
62 shape->SetLocked( true );
63 footprint->Add( shape );
64
65 BOOST_CHECK( !PCB_SELECTION_TOOL::HasLockedDescendant( footprint ) );
66}
67
68
69BOOST_AUTO_TEST_CASE( LockedMemberPinsGroup )
70{
71 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
72
73 PCB_SHAPE* shape = new PCB_SHAPE( board.get(), SHAPE_T::SEGMENT );
74 shape->SetLocked( true );
75 board->Add( shape );
76
77 PCB_GROUP* group = new PCB_GROUP( board.get() );
78 group->AddItem( shape );
79 board->Add( group );
80
82}
83
84
85BOOST_AUTO_TEST_CASE( LockedFootprintPinsGroup )
86{
87 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
88
89 FOOTPRINT* footprint = new FOOTPRINT( board.get() );
90 footprint->SetLocked( true );
91 board->Add( footprint );
92
93 PCB_GROUP* group = new PCB_GROUP( board.get() );
94 group->AddItem( footprint );
95 board->Add( group );
96
98}
99
100
101BOOST_AUTO_TEST_CASE( LockedFieldDoesNotPinGroupHoldingFootprint )
102{
103 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
104
105 FOOTPRINT* footprint = new FOOTPRINT( board.get() );
106 board->Add( footprint );
107
108 footprint->Reference().SetLocked( true );
109
110 PCB_GROUP* group = new PCB_GROUP( board.get() );
111 group->AddItem( footprint );
112 board->Add( group );
113
115}
116
117
void SetLocked(bool aLocked) override
Definition board_item.h:367
bool IsLocked() const override
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition footprint.h:647
bool IsLocked() const override
Definition footprint.h:637
PCB_FIELD & Reference()
Definition footprint.h:881
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:51
static bool HasLockedDescendant(const BOARD_ITEM *aItem)
@ SEGMENT
Definition eda_shape.h:46
Class to handle a set of BOARD_ITEMs.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(LockedFieldDoesNotPinFootprint)