20#include <boost/test/unit_test.hpp>
32#include <wx/filename.h>
41class TEMP_SYMBOL_LIBRARY
46 m_dir = wxFileName::CreateTempFileName( wxS(
"kicad_qa_sch_line_ending_io_" ) );
47 wxRemoveFile( m_dir );
48 wxFileName::Mkdir( m_dir );
50 m_path = wxFileName( m_dir, wxS(
"line_ending_roundtrip.kicad_sym" ) ).GetFullPath();
53 ~TEMP_SYMBOL_LIBRARY()
55 if( wxFileName::DirExists( m_dir ) )
56 wxFileName::Rmdir( m_dir, wxPATH_RMDIR_RECURSIVE );
59 const wxString& Path()
const {
return m_path; }
97 if( shape && shape->
GetShape() == aShape )
109 TEMP_SYMBOL_LIBRARY tempLib;
111 LIB_SYMBOL symbol( wxS(
"LineEndingSymbol" ) );
117 poly->AddPoint(
VECTOR2I( 1000, 0 ) );
118 poly->AddPoint(
VECTOR2I( 1000, 500 ) );
130 bezier->SetStart(
VECTOR2I( 0, 2000 ) );
131 bezier->SetBezierC1(
VECTOR2I( 300, 2500 ) );
132 bezier->SetBezierC2(
VECTOR2I( 700, 1500 ) );
133 bezier->SetEnd(
VECTOR2I( 1000, 2000 ) );
135 setEndings( bezier );
142 io.
SaveSymbol( tempLib.Path(), std::make_unique<LIB_SYMBOL>( symbol ) );
153 SCH_SHAPE* shape = findSymbolShape( loaded, shapeType );
154 BOOST_REQUIRE_MESSAGE( shape,
"Expected symbol shape was not reloaded" );
173 BOOST_CHECK( bbox.
GetRight() >= 1200 );
174 BOOST_CHECK( bbox.
GetTop() <= -200 );
190 BOOST_CHECK( bbox.
GetRight() < 1200 );
206 BOOST_CHECK( line.
HitTest( selection,
false, 0 ) );
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
void SetEndEndingLength(int aLength)
void SetStartEndingStyle(LINE_ENDING_STYLE aStyle)
void SetEndEndingWidth(int aWidth)
void SetEndEndingStyle(LINE_ENDING_STYLE aStyle)
void SetStartEndingLength(int aLength)
void SetEndEndingStrokeWidth(int aWidth)
void SetStartEndingWidth(int aWidth)
const LINE_ENDING & GetStartEnding() const
const LINE_ENDING & GetEndEnding() const
void SetStartEndingStrokeWidth(int aWidth)
Define a library symbol object.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
wxString GetName() const override
SCH_FIELD & GetValueField()
Return reference to the value field.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
Decorative shape (arrowhead, circle, square) at the start or end of a graphic line,...
int GetLength() const
Along-line size. 0 = auto.
int GetWidth() const
Perpendicular size. 0 = auto.
LINE_ENDING_STYLE GetStyle() const
int GetStrokeWidth() const
Outline stroke width.
void SetText(const wxString &aText) override
A SCH_IO derivation for loading schematic files using the new s-expression file format.
void SaveLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
void CreateLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Create a new empty library at aLibraryPath empty.
void SaveSymbol(const wxString &aLibraryPath, std::unique_ptr< LIB_SYMBOL > aSymbol, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSymbol to an existing library located at aLibraryPath.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Segment description base class to describe items which have 2 end points (track, wire,...
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void SetEndEndingStyle(LINE_ENDING_STYLE aStyle)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetEndEndingWidth(int aWidth)
void SetLineWidth(const int aSize)
void SetEndEndingLength(int aLength)
void SetEndPoint(const VECTOR2I &aPosition)
Simple container to manage line stroke parameters.
LINE_ENDING_STYLE
Line ending styles for graphic lines, arcs, and beziers.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(SymbolLibraryLineEndingsRoundTrip)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I