20#include <boost/test/unit_test.hpp>
33#include <wx/filename.h>
34#include <wx/stdpaths.h>
42 wxString tempDir = wxStandardPaths::Get().GetTempDir();
43 wxString projectPath = tempDir + wxFileName::GetPathSeparator() + wxT(
"test_sch_ellipse.kicad_pro" );
47 m_schematic = std::make_unique<SCHEMATIC>(
nullptr );
56 if( wxFileExists( file ) )
65 wxString tempDir = wxStandardPaths::Get().GetTempDir();
66 wxString fileName = wxFileName::CreateTempFileName( tempDir + wxFileName::GetPathSeparator() + aPrefix );
80 std::vector<SCH_SHEET*> topSheets =
m_schematic->GetTopLevelSheets();
81 SCH_SCREEN* screen = topSheets[0]->GetScreen();
87 fileName +=
".kicad_sch";
109 if( ps->GetShape() == shapeType )
130 shape->SetEllipseCenter(
VECTOR2I( 2540, 5080 ) );
131 shape->SetEllipseMajorRadius( 1270 );
132 shape->SetEllipseMinorRadius( 762 );
136 SCH_SHAPE* found = RoundTrip( shape,
"sch_ellipse_closed" );
137 BOOST_REQUIRE_MESSAGE( found,
"Schematic ellipse not found after roundtrip" );
150 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
151 shape->SetEllipseMajorRadius( 1016 );
152 shape->SetEllipseMinorRadius( 635 );
158 SCH_SHAPE* found = RoundTrip( shape,
"sch_ellipse_arc" );
159 BOOST_REQUIRE_MESSAGE( found,
"Schematic elliptical arc not found after roundtrip" );
172 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
173 shape->SetEllipseMajorRadius( 2000 );
174 shape->SetEllipseMinorRadius( 1000 );
178 SCH_SHAPE* found = RoundTrip( shape,
"sch_ellipse_negrot" );
179 BOOST_REQUIRE_MESSAGE( found,
"Schematic ellipse not found after roundtrip" );
188 shape->SetEllipseCenter(
VECTOR2I( 1000, 1000 ) );
189 shape->SetEllipseMajorRadius( 500 );
190 shape->SetEllipseMinorRadius( 300 );
191 shape->SetEllipseRotation(
ANGLE_0 );
195 SCH_SHAPE* found = RoundTrip( shape,
"sch_ellipse_stroke_fill" );
196 BOOST_REQUIRE_MESSAGE( found,
"Schematic ellipse not found after roundtrip" );
206 auto symbol = std::make_unique<LIB_SYMBOL>( wxT(
"TestEllipse" ),
nullptr );
209 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
210 shape->SetEllipseMajorRadius( 508 );
211 shape->SetEllipseMinorRadius( 254 );
214 symbol->AddDrawItem( shape );
219 for(
SCH_ITEM& item : symbol->GetDrawItems() )
231 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in symbol draw items" );
240 auto symbol = std::make_unique<LIB_SYMBOL>( wxT(
"TestEllipseArc" ),
nullptr );
243 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
244 shape->SetEllipseMajorRadius( 762 );
245 shape->SetEllipseMinorRadius( 381 );
250 symbol->AddDrawItem( shape );
254 for(
SCH_ITEM& item : symbol->GetDrawItems() )
266 BOOST_REQUIRE_MESSAGE( found,
"Elliptical arc not found in symbol draw items" );
278 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
279 shape->SetEllipseMajorRadius( 500 );
280 shape->SetEllipseMinorRadius( 300 );
281 shape->SetEllipseRotation(
ANGLE_0 );
286 SCH_SHAPE* found = RoundTrip( shape,
"sch_ellipse_arc_eq" );
287 BOOST_REQUIRE_MESSAGE( found,
"Schematic elliptical arc not found after roundtrip" );
296 auto symbol = std::make_unique<LIB_SYMBOL>( wxT(
"TestEllipseFill" ),
nullptr );
299 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
300 shape->SetEllipseMajorRadius( 762 );
301 shape->SetEllipseMinorRadius( 381 );
302 shape->SetEllipseRotation(
ANGLE_0 );
305 symbol->AddDrawItem( shape );
309 for(
SCH_ITEM& item : symbol->GetDrawItems() )
321 BOOST_REQUIRE_MESSAGE( found,
"Ellipse not found in symbol draw items" );
329 shape->SetEllipseCenter(
VECTOR2I( 0, 0 ) );
330 shape->SetEllipseMajorRadius( 1 );
331 shape->SetEllipseMinorRadius( 1 );
332 shape->SetEllipseRotation(
ANGLE_0 );
335 SCH_SHAPE* found = RoundTrip( shape,
"sch_ellipse_minradii" );
336 BOOST_REQUIRE_MESSAGE( found,
"Schematic ellipse not found after roundtrip" );
351 shape->SetEllipseCenter(
VECTOR2I( 3810, 7620 ) );
352 shape->SetEllipseMajorRadius( 2540 );
353 shape->SetEllipseMinorRadius( 1270 );
358 SCH_SHAPE* found = RoundTrip( shape,
"sch_ellipse_all_fields" );
359 BOOST_REQUIRE_MESSAGE( found,
"Schematic ellipse not found after roundtrip" );
380 shape->SetEllipseCenter(
VECTOR2I( 1270, 2540 ) );
381 shape->SetEllipseMajorRadius( 5080 );
382 shape->SetEllipseMinorRadius( 2540 );
388 SCH_SHAPE* found = RoundTrip( shape,
"sch_ellipse_arc_all_fields" );
389 BOOST_REQUIRE_MESSAGE( found,
"Schematic elliptical arc not found after roundtrip" );
int GetEllipseMinorRadius() const
const VECTOR2I & GetEllipseCenter() const
EDA_ANGLE GetEllipseEndAngle() const
FILL_T GetFillMode() const
int GetEllipseMajorRadius() const
EDA_ANGLE GetEllipseRotation() const
EDA_ANGLE GetEllipseStartAngle() const
Container for project specific data.
A SCH_IO derivation for loading schematic files using the new s-expression file format.
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
STROKE_PARAMS GetStroke() const override
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_SCREEN * GetScreen() const
Simple container to manage line stroke parameters.
LINE_STYLE GetLineStyle() const
static constexpr EDA_ANGLE ANGLE_0
@ FILLED_SHAPE
Fill with object color.
wxString GetTempFileName(const wxString &aPrefix)
SETTINGS_MANAGER m_settingsManager
std::vector< wxString > m_tempFiles
std::unique_ptr< SCHEMATIC > m_schematic
SCH_SHAPE * RoundTrip(SCH_SHAPE *aShape, const wxString &aTag)
Helper: add a SCH_SHAPE to the first screen, save, reload, and return the matching shape from the rel...
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(SchematicClosedEllipse)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I