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
21 SCH_SCREEN* screen = new SCH_SCREEN( nullptr );
22 SCH_SHEET* sheet = new SCH_SHEET( nullptr, VECTOR2I( 0, 0 ), VECTOR2I( 1000, 1000 ) );
23 sheet->SetScreen( screen );
24 schematic.SetRoot( sheet );
25
26 CONNECTION_GRAPH graph;
27 graph.SetSchematic( &schematic );
28
29 SCH_SHEET_PATH sheetPath;
30 sheetPath.push_back( sheet );
31
32 SCH_LINE* h = new SCH_LINE( VECTOR2I( -1000, 0 ), LAYER_WIRE );
33 h->SetEndPoint( VECTOR2I( 1000, 0 ) );
34 SCH_LINE* v = new SCH_LINE( VECTOR2I( 0, -1000 ), LAYER_WIRE );
35 v->SetEndPoint( VECTOR2I( 0, 1000 ) );
36 SCH_LABEL* label = new SCH_LABEL( VECTOR2I( 0, 0 ), wxS( "N" ) );
37 screen->Append( h, false );
38 screen->Append( v, false );
39 screen->Append( label, false );
40
41 std::vector<SCH_ITEM*> items = { h, v, label };
42
43 label->GetOrInitConnection( sheetPath, &graph )->ConfigureFromLabel(wxS("N"));
44
46 graph.Recalculate( sheets, true );
47
50
51 BOOST_REQUIRE( sg1 );
52 BOOST_REQUIRE( sg2 );
53 BOOST_CHECK( sg1 == sg2 );
54 BOOST_CHECK( sg1->GetDriver() == label );
55 BOOST_CHECK( sg2->GetDriver() == label );
56}
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
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const
Definition schematic.h:108
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
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:428
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:145
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:47
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:451
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