KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_crossing_label.cpp
Go to the documentation of this file.
2
3#include <connection_graph.h>
4#include <sch_line.h>
5#include <sch_label.h>
6#include <sch_sheet.h>
7#include <sch_sheet_path.h>
8#include <sch_screen.h>
9#include <schematic.h>
11#include <project.h>
12
13BOOST_AUTO_TEST_CASE( LabelDrivesCrossingWires )
14{
15
16 SETTINGS_MANAGER manager;
17 manager.LoadProject( "" );
18
19 SCHEMATIC schematic( &manager.Prj() );
20 schematic.Reset();
21 SCH_SHEET* defaultSheet = schematic.GetTopLevelSheet( 0 );
22
23 SCH_SCREEN* screen = new SCH_SCREEN( nullptr );
24 SCH_SHEET* sheet = new SCH_SHEET( nullptr, VECTOR2I( 0, 0 ), VECTOR2I( 1000, 1000 ) );
25 sheet->SetScreen( screen );
26 schematic.AddTopLevelSheet( sheet );
27 schematic.RemoveTopLevelSheet( defaultSheet );
28 delete defaultSheet;
29
30 CONNECTION_GRAPH graph;
31 graph.SetSchematic( &schematic );
32
33 SCH_SHEET_PATH sheetPath;
34 sheetPath.push_back( sheet );
35
36 SCH_LINE* h = new SCH_LINE( VECTOR2I( -1000, 0 ), LAYER_WIRE );
37 h->SetEndPoint( VECTOR2I( 1000, 0 ) );
38 SCH_LINE* v = new SCH_LINE( VECTOR2I( 0, -1000 ), LAYER_WIRE );
39 v->SetEndPoint( VECTOR2I( 0, 1000 ) );
40 SCH_LABEL* label = new SCH_LABEL( VECTOR2I( 0, 0 ), wxS( "N" ) );
41 screen->Append( h, false );
42 screen->Append( v, false );
43 screen->Append( label, false );
44
45 std::vector<SCH_ITEM*> items = { h, v, label };
46
47 label->GetOrInitConnection( sheetPath, &graph )->ConfigureFromLabel(wxS("N"));
48
50 graph.Recalculate( sheets, true );
51
54
55 BOOST_REQUIRE( sg1 );
56 BOOST_REQUIRE( sg2 );
57 BOOST_CHECK( sg1 == sg2 );
58 BOOST_CHECK( sg1->GetDriver() == label );
59 BOOST_CHECK( sg2->GetDriver() == label );
60}
Calculate the connectivity of a schematic and generates netlists.
void SetSchematic(SCHEMATIC *aSchematic)
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Update the connection graph for the given list of sheets.
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem) const
A subgraph is a set of items that are electrically connected on a single sheet.
const SCH_ITEM * GetDriver() const
Holds all the data relating to one schematic.
Definition schematic.h:88
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
void AddTopLevelSheet(SCH_SHEET *aSheet)
Add a new top-level sheet to the schematic.
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const
SCH_SHEET * GetTopLevelSheet(int aIndex=0) const
bool RemoveTopLevelSheet(SCH_SHEET *aSheet)
Remove a top-level sheet from the schematic.
void ConfigureFromLabel(const wxString &aLabel)
Configures the connection given a label.
SCH_CONNECTION * GetOrInitConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Definition sch_item.cpp:578
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:42
void SetEndPoint(const VECTOR2I &aPosition)
Definition sch_line.h:149
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
@ LAYER_WIRE
Definition layer_ids.h:452
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
BOOST_AUTO_TEST_CASE(LabelDrivesCrossingWires)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695