Browse Source
Fix incremental connectivity
Fix incremental connectivity
The connectivity routine would consider symbols, overwriting unused
subgraphs for pins that were not in the change list. This is resolved
by updating the full connectivity to only use pins in the graph since
symbols are not connected independently.
In the process of adding QA tests for this change, additional issues
with the schematic QA were discovered. Specifically, we were not
properly setting the root sheet UUID. This was partially masked by a
const_cast setting of the RefDes in sch_symbol when called the RefDes
getter. This exposed the fact that our QA ERC numbers did not match the
schematic editor stand alone ERC numbers. So the test value for one
check needed to be updated
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17528
(cherry picked from commit a9f35ba42e)
8.0
14 changed files with 891 additions and 80 deletions
-
162eeschema/connection_graph.cpp
-
2eeschema/connection_graph.h
-
1eeschema/files-io.cpp
-
23eeschema/sch_edit_frame.cpp
-
23eeschema/sch_item.cpp
-
11eeschema/sch_item.h
-
2eeschema/sch_label.cpp
-
1eeschema/sch_symbol.cpp
-
478qa/data/eeschema/incremental_test.kicad_sch
-
99qa/data/eeschema/issue13591.kicad_pro
-
2qa/schematic_utils/schematic_file_util.cpp
-
1qa/tests/eeschema/CMakeLists.txt
-
2qa/tests/eeschema/erc/test_erc_hierarchical_schematics.cpp
-
164qa/tests/eeschema/test_incremental_netlister.cpp
@ -0,0 +1,478 @@ |
|||
(kicad_sch |
|||
(version 20231120) |
|||
(generator "eeschema") |
|||
(generator_version "8.0") |
|||
(uuid "5e4124ac-877c-4d6f-a16b-822110ac68a1") |
|||
(paper "A4") |
|||
(lib_symbols |
|||
(symbol "Connector:TestPoint" |
|||
(pin_numbers hide) |
|||
(pin_names |
|||
(offset 0.762) hide) |
|||
(exclude_from_sim no) |
|||
(in_bom yes) |
|||
(on_board yes) |
|||
(property "Reference" "TP" |
|||
(at 0 6.858 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
(property "Value" "TestPoint" |
|||
(at 0 5.08 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
(property "Footprint" "" |
|||
(at 5.08 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Datasheet" "~" |
|||
(at 5.08 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Description" "test point" |
|||
(at 0 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "ki_keywords" "test point tp" |
|||
(at 0 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "ki_fp_filters" "Pin* Test*" |
|||
(at 0 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(symbol "TestPoint_0_1" |
|||
(circle |
|||
(center 0 3.302) |
|||
(radius 0.762) |
|||
(stroke |
|||
(width 0) |
|||
(type default) |
|||
) |
|||
(fill |
|||
(type none) |
|||
) |
|||
) |
|||
) |
|||
(symbol "TestPoint_1_1" |
|||
(pin passive line |
|||
(at 0 0 90) |
|||
(length 2.54) |
|||
(name "1" |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
(number "1" |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
(symbol "power:GND" |
|||
(power) |
|||
(pin_numbers hide) |
|||
(pin_names |
|||
(offset 0) hide) |
|||
(exclude_from_sim no) |
|||
(in_bom yes) |
|||
(on_board yes) |
|||
(property "Reference" "#PWR" |
|||
(at 0 -6.35 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Value" "GND" |
|||
(at 0 -3.81 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
(property "Footprint" "" |
|||
(at 0 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Datasheet" "" |
|||
(at 0 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Description" "Power symbol creates a global label with name \"GND\" , ground" |
|||
(at 0 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "ki_keywords" "global power" |
|||
(at 0 0 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(symbol "GND_0_1" |
|||
(polyline |
|||
(pts |
|||
(xy 0 0) (xy 0 -1.27) (xy 1.27 -1.27) (xy 0 -2.54) (xy -1.27 -1.27) (xy 0 -1.27) |
|||
) |
|||
(stroke |
|||
(width 0) |
|||
(type default) |
|||
) |
|||
(fill |
|||
(type none) |
|||
) |
|||
) |
|||
) |
|||
(symbol "GND_1_1" |
|||
(pin power_in line |
|||
(at 0 0 270) |
|||
(length 0) |
|||
(name "~" |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
(number "1" |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
(symbol |
|||
(lib_id "Connector:TestPoint") |
|||
(at 82.55 88.9 0) |
|||
(unit 1) |
|||
(exclude_from_sim no) |
|||
(in_bom yes) |
|||
(on_board yes) |
|||
(dnp no) |
|||
(fields_autoplaced yes) |
|||
(uuid "86891145-73fb-48da-aca6-492a4fb35190") |
|||
(property "Reference" "TP1" |
|||
(at 85.09 84.328 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(justify left) |
|||
) |
|||
) |
|||
(property "Value" "TestPoint" |
|||
(at 85.09 86.868 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(justify left) |
|||
) |
|||
) |
|||
(property "Footprint" "" |
|||
(at 87.63 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Datasheet" "~" |
|||
(at 87.63 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Description" "test point" |
|||
(at 82.55 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(pin "1" |
|||
(uuid "2bf2be02-e7d9-4e42-8e57-404647a392eb") |
|||
) |
|||
(instances |
|||
(project "" |
|||
(path "/5e4124ac-877c-4d6f-a16b-822110ac68a1" |
|||
(reference "TP1") |
|||
(unit 1) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
(symbol |
|||
(lib_id "power:GND") |
|||
(at 82.55 88.9 0) |
|||
(unit 1) |
|||
(exclude_from_sim no) |
|||
(in_bom yes) |
|||
(on_board yes) |
|||
(dnp no) |
|||
(fields_autoplaced yes) |
|||
(uuid "b9e595cb-65cf-4cf6-b2cb-772d3688abf0") |
|||
(property "Reference" "#PWR01" |
|||
(at 82.55 95.25 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Value" "GND" |
|||
(at 82.55 93.98 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
(property "Footprint" "" |
|||
(at 82.55 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Datasheet" "" |
|||
(at 82.55 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Description" "Power symbol creates a global label with name \"GND\" , ground" |
|||
(at 82.55 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(pin "1" |
|||
(uuid "e434aab5-d764-4bd8-a761-696fb56ace19") |
|||
) |
|||
(instances |
|||
(project "" |
|||
(path "/5e4124ac-877c-4d6f-a16b-822110ac68a1" |
|||
(reference "#PWR01") |
|||
(unit 1) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
(symbol |
|||
(lib_id "Connector:TestPoint") |
|||
(at 99.06 88.9 0) |
|||
(unit 1) |
|||
(exclude_from_sim no) |
|||
(in_bom yes) |
|||
(on_board yes) |
|||
(dnp no) |
|||
(fields_autoplaced yes) |
|||
(uuid "d4520136-e0ab-467d-b271-26033a078cb6") |
|||
(property "Reference" "TP2" |
|||
(at 101.6 84.328 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(justify left) |
|||
) |
|||
) |
|||
(property "Value" "TestPoint" |
|||
(at 101.6 86.868 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(justify left) |
|||
) |
|||
) |
|||
(property "Footprint" "" |
|||
(at 104.14 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Datasheet" "~" |
|||
(at 104.14 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Description" "test point" |
|||
(at 99.06 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(pin "1" |
|||
(uuid "2bf2be02-e7d9-4e42-8e57-404647a392eb") |
|||
) |
|||
(instances |
|||
(project "" |
|||
(path "/5e4124ac-877c-4d6f-a16b-822110ac68a1" |
|||
(reference "TP2") |
|||
(unit 1) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
(symbol |
|||
(lib_id "power:GND") |
|||
(at 99.06 88.9 0) |
|||
(unit 1) |
|||
(exclude_from_sim no) |
|||
(in_bom yes) |
|||
(on_board yes) |
|||
(dnp no) |
|||
(fields_autoplaced yes) |
|||
(uuid "fa30dd75-0d78-423e-a304-836357e80e2f") |
|||
(property "Reference" "#PWR02" |
|||
(at 99.06 95.25 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Value" "GND" |
|||
(at 99.06 93.98 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
) |
|||
) |
|||
(property "Footprint" "" |
|||
(at 99.06 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Datasheet" "" |
|||
(at 99.06 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(property "Description" "Power symbol creates a global label with name \"GND\" , ground" |
|||
(at 99.06 88.9 0) |
|||
(effects |
|||
(font |
|||
(size 1.27 1.27) |
|||
) |
|||
(hide yes) |
|||
) |
|||
) |
|||
(pin "1" |
|||
(uuid "e434aab5-d764-4bd8-a761-696fb56ace19") |
|||
) |
|||
(instances |
|||
(project "" |
|||
(path "/5e4124ac-877c-4d6f-a16b-822110ac68a1" |
|||
(reference "#PWR02") |
|||
(unit 1) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
(sheet_instances |
|||
(path "/" |
|||
(page "1") |
|||
) |
|||
) |
|||
) |
|||
@ -0,0 +1,164 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2024 KiCad Developers, see AUTHORS.TXT for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 3 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* https://www.gnu.org/licenses/gpl-3.0.en.html
|
|||
* or you may search the http://www.gnu.org website for the version 32 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
|
|||
#include <qa_utils/wx_utils/unit_test_utils.h>
|
|||
#include <schematic_utils/schematic_file_util.h>
|
|||
|
|||
#include <connection_graph.h>
|
|||
#include <schematic.h>
|
|||
#include <sch_sheet.h>
|
|||
#include <sch_screen.h>
|
|||
#include <settings/settings_manager.h>
|
|||
#include <locale_io.h>
|
|||
|
|||
struct INCREMENTAL_NETLIST_TEST_FIXTURE |
|||
{ |
|||
INCREMENTAL_NETLIST_TEST_FIXTURE() : |
|||
m_settingsManager( true /* headless */ ) |
|||
{ } |
|||
|
|||
SETTINGS_MANAGER m_settingsManager; |
|||
std::unique_ptr<SCHEMATIC> m_schematic; |
|||
}; |
|||
|
|||
BOOST_FIXTURE_TEST_CASE( RemoveAddItems, INCREMENTAL_NETLIST_TEST_FIXTURE ) |
|||
{ |
|||
LOCALE_IO dummy; |
|||
|
|||
// Check for Errors when using global labels
|
|||
std::vector<wxString> tests = {// "incremental_test",
|
|||
// "issue10430",
|
|||
// "issue10926_1",
|
|||
// "issue11926",
|
|||
// "issue12505",
|
|||
// "issue12814",
|
|||
// "issue13112",
|
|||
// "issue13162",
|
|||
// "issue13212",
|
|||
// "issue13431",
|
|||
// "issue13591",
|
|||
// "issue16223",
|
|||
// "issue6588",
|
|||
"issue7203"};//,
|
|||
// "issue9367"};
|
|||
|
|||
for( const wxString& test : tests ) |
|||
{ |
|||
KI_TEST::LoadSchematic( m_settingsManager, test, m_schematic ); |
|||
|
|||
SCH_SHEET_LIST sheets = m_schematic->GetSheets(); |
|||
|
|||
for( const SCH_SHEET_PATH& path : sheets ) |
|||
{ |
|||
for( size_t ii = 0; ii < path.size(); ++ii ) |
|||
{ |
|||
const SCH_SHEET* sheet = path.GetSheet( ii ); |
|||
const SCH_SCREEN* screen = sheet->GetScreen(); |
|||
std::vector<SCH_ITEM*> items; |
|||
|
|||
for( SCH_ITEM* item : screen->Items() ) |
|||
{ |
|||
if( !item->IsConnectable() ) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
if( item->Type() == SCH_SYMBOL_T ) |
|||
{ |
|||
for( SCH_PIN* pin : static_cast<SCH_SYMBOL*>( item )->GetPins() ) |
|||
{ |
|||
items.push_back( pin ); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
items.push_back( item ); |
|||
} |
|||
} |
|||
|
|||
for( SCH_ITEM* item : items ) |
|||
{ |
|||
for( SCH_ITEM* check_item : items ) |
|||
{ |
|||
auto& conn_items = check_item->ConnectedItems( path ); |
|||
auto conn = check_item->Connection(); |
|||
std::string netname = conn ? conn->GetNetName().ToStdString() : "NoNet"; |
|||
int subgraph = conn ? conn->SubgraphCode() : -1; |
|||
BOOST_TEST_MESSAGE( test.ToStdString() << ": Item " |
|||
<< check_item->GetFriendlyName().ToStdString() |
|||
<< " in net " << netname << " subgraph " << subgraph |
|||
<< " has " << conn_items.size() << " connections" ); |
|||
} |
|||
SCH_CONNECTION* connection = item->Connection(); |
|||
|
|||
if( !connection ) |
|||
continue; |
|||
|
|||
wxString netname = connection->GetNetName(); |
|||
|
|||
if( !item->IsConnectable() ) |
|||
continue; |
|||
|
|||
SCH_ITEM_VEC prev_items = item->ConnectedItems( path ); |
|||
std::sort( prev_items.begin(), prev_items.end() ); |
|||
alg::remove_duplicates( prev_items ); |
|||
|
|||
|
|||
std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items = |
|||
m_schematic->ConnectionGraph()->ExtractAffectedItems( { item } ); |
|||
all_items.insert( { path, item } ); |
|||
BOOST_TEST_MESSAGE( test.ToStdString() << ": Item " |
|||
<< item->GetFriendlyName().ToStdString() |
|||
<< " in net " << netname.ToStdString() |
|||
<< " has " << all_items.size() << " affected items" ); |
|||
|
|||
CONNECTION_GRAPH new_graph( m_schematic.get() ); |
|||
|
|||
new_graph.SetLastCodes( m_schematic->ConnectionGraph() ); |
|||
|
|||
for( auto&[ path, item ] : all_items ) |
|||
{ |
|||
wxCHECK2( item, continue ); |
|||
item->SetConnectivityDirty(); |
|||
} |
|||
|
|||
new_graph.Recalculate( sheets, false ); |
|||
m_schematic->ConnectionGraph()->Merge( new_graph ); |
|||
|
|||
SCH_ITEM_VEC curr_items = item->ConnectedItems( path ); |
|||
std::sort( curr_items.begin(), curr_items.end() ); |
|||
alg::remove_duplicates( curr_items ); |
|||
|
|||
BOOST_CHECK_MESSAGE( prev_items == curr_items, |
|||
test.ToStdString() << ": Item " |
|||
<< item->GetFriendlyName().ToStdString() |
|||
<< " in net " << netname.ToStdString() |
|||
<< " changed from " << prev_items.size() |
|||
<< " to " << curr_items.size() << " Location:" << item->GetPosition().x << "," << item->GetPosition().y ); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue