30#include <boost/test/unit_test.hpp>
48#include <wx/mstream.h>
57 std::unique_ptr<SCH_LINE>
CreateWire(
int x1,
int y1,
int x2,
int y2 )
59 auto wire = std::make_unique<SCH_LINE>(
63 m_items.push_back( wire.get() );
67 std::unique_ptr<SCH_LINE>
CreateBus(
int x1,
int y1,
int x2,
int y2 )
69 auto bus = std::make_unique<SCH_LINE>(
79 auto junction = std::make_unique<SCH_JUNCTION>(
81 m_items.push_back( junction.get() );
87 auto noConnect = std::make_unique<SCH_NO_CONNECT>(
89 m_items.push_back( noConnect.get() );
95 auto entry = std::make_unique<SCH_BUS_WIRE_ENTRY>(
97 m_items.push_back( entry.get() );
103 auto schText = std::make_unique<SCH_TEXT>(
106 m_items.push_back( schText.get() );
112 auto label = std::make_unique<SCH_LABEL>(
114 m_items.push_back( label.get() );
120 auto label = std::make_unique<SCH_GLOBALLABEL>(
122 m_items.push_back( label.get() );
128 auto label = std::make_unique<SCH_HIERLABEL>(
130 m_items.push_back( label.get() );
140 m_items.push_back( rect.get() );
154 std::unique_ptr<SCH_SHAPE>
CreatePolyline(
const std::vector<std::pair<int, int>>& points )
159 for(
const auto& pt : points )
162 m_items.push_back( poly.get() );
183 auto wire = CreateWire( 0, 0, 100, 0 );
185 BOOST_CHECK( wire !=
nullptr );
186 BOOST_CHECK( wire->IsWire() );
197 auto bus = CreateBus( 0, 0, 0, 100 );
199 BOOST_CHECK( bus !=
nullptr );
200 BOOST_CHECK( bus->IsBus() );
209 auto junction = CreateJunction( 50, 50 );
211 BOOST_CHECK( junction !=
nullptr );
222 auto noConnect = CreateNoConnect( 100, 100 );
224 BOOST_CHECK( noConnect !=
nullptr );
234 auto entry = CreateBusEntry( 150, 150 );
236 BOOST_CHECK( entry !=
nullptr );
246 auto text = CreateText( 200, 200, wxT(
"Test Text" ) );
248 BOOST_CHECK(
text !=
nullptr );
249 BOOST_CHECK(
text->GetText() == wxT(
"Test Text" ) );
258 auto label = CreateLabel( 0, 0, wxT(
"NET1" ) );
259 auto globalLabel = CreateGlobalLabel( 100, 0, wxT(
"VCC" ) );
260 auto hierLabel = CreateHierLabel( 200, 0, wxT(
"DATA_IN" ) );
262 BOOST_CHECK( label !=
nullptr );
263 BOOST_CHECK( globalLabel !=
nullptr );
264 BOOST_CHECK( hierLabel !=
nullptr );
277 auto rect = CreateRectangle( 0, 0, 100, 100 );
278 auto circle = CreateCircle( 200, 50, 50 );
279 auto poly = CreatePolyline( { { 300, 0 }, { 350, 50 }, { 300, 100 } } );
281 BOOST_CHECK( rect !=
nullptr );
282 BOOST_CHECK(
circle !=
nullptr );
283 BOOST_CHECK( poly !=
nullptr );
296 auto wire1 = CreateWire( 0, 0, 100, 0 );
297 auto wire2 = CreateWire( 0, 0, 0, 100 );
312 auto wire = CreateWire( 0, 0, 100, 0 );
313 auto junction = CreateJunction( 100, 0 );
314 auto text = CreateText( 150, 0, wxT(
"Label" ) );
328 auto rect = CreateRectangle( -50, -50, 50, 50 );
359 int rW = 128, gW = 128, bW = 128;
360 int rB = 128, gB = 128, bB = 128;
365 int avgDiff = ( diffR + diffG + diffB ) / 3;
366 int alpha = 255 - avgDiff;
378 int rW = 255, gW = 255, bW = 255;
379 int rB = 0, gB = 0, bB = 0;
384 int avgDiff = ( diffR + diffG + diffB ) / 3;
385 int alpha = 255 - avgDiff;
398 auto wire1 = CreateWire( 0, 0, 200, 0 );
399 auto wire2 = CreateWire( 200, 0, 200, 100 );
402 auto junction = CreateJunction( 200, 0 );
405 auto bus = CreateBus( 0, 200, 300, 200 );
406 auto busEntry = CreateBusEntry( 150, 200 );
409 auto label = CreateLabel( 50, -20, wxT(
"NET_A" ) );
410 auto globalLabel = CreateGlobalLabel( 250, 50, wxT(
"VCC" ) );
413 auto text = CreateText( 100, 300, wxT(
"Note: Power section" ) );
416 auto rect = CreateRectangle( -50, -50, 350, 350 );
420 BOOST_CHECK( wire1->IsWire() );
421 BOOST_CHECK( wire2->IsWire() );
422 BOOST_CHECK( bus->IsBus() );
constexpr EDA_IU_SCALE schIUScale
std::unique_ptr< SCH_SHAPE > CreateRectangle(int x1, int y1, int x2, int y2)
std::unique_ptr< SCH_LINE > CreateBus(int x1, int y1, int x2, int y2)
~SCHEMATIC_CLIPBOARD_FIXTURE()=default
std::unique_ptr< SCH_BUS_WIRE_ENTRY > CreateBusEntry(int x, int y)
std::unique_ptr< SCH_LINE > CreateWire(int x1, int y1, int x2, int y2)
std::unique_ptr< SCH_GLOBALLABEL > CreateGlobalLabel(int x, int y, const wxString &text)
SCHEMATIC_CLIPBOARD_FIXTURE()=default
std::vector< SCH_ITEM * > m_items
std::unique_ptr< SCH_JUNCTION > CreateJunction(int x, int y)
std::unique_ptr< SCH_LABEL > CreateLabel(int x, int y, const wxString &text)
std::unique_ptr< SCH_SHAPE > CreatePolyline(const std::vector< std::pair< int, int > > &points)
std::unique_ptr< SCH_SHAPE > CreateCircle(int cx, int cy, int radius)
std::unique_ptr< SCH_HIERLABEL > CreateHierLabel(int x, int y, const wxString &text)
std::unique_ptr< SCH_NO_CONNECT > CreateNoConnect(int x, int y)
std::unique_ptr< SCH_TEXT > CreateText(int x, int y, const wxString &text)
Simple container to manage line stroke parameters.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Plotting engines similar to ps (PostScript, Gerber, svg)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ElementCreation_Wires)
Test that wires can be created for export testing.
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I