24#include <boost/test/unit_test.hpp>
26#include <wx/filename.h>
43 BOOST_CHECK( plotter.
StartPlot( wxEmptyString ) );
44 BOOST_CHECK( plotter.
EndPlot() );
46 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"png_test" ) ) + wxS(
".png" );
47 BOOST_CHECK( plotter.
SaveFile( tempFile ) );
50 BOOST_CHECK( wxFileExists( tempFile ) );
53 wxImage img( tempFile );
54 BOOST_CHECK( img.IsOk() );
58 wxRemoveFile( tempFile );
73 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"png_rect" ) ) + wxS(
".png" );
74 BOOST_CHECK( plotter.
SaveFile( tempFile ) );
76 wxImage img( tempFile );
77 BOOST_CHECK( img.IsOk() );
80 unsigned char r = img.GetRed( 50, 50 );
81 unsigned char g = img.GetGreen( 50, 50 );
82 unsigned char b = img.GetBlue( 50, 50 );
83 BOOST_CHECK_GT( r, 200 );
84 BOOST_CHECK_LT( g, 50 );
85 BOOST_CHECK_LT( b, 50 );
87 wxRemoveFile( tempFile );
115 std::vector<VECTOR2I> pts;
117 for(
int j = 0; j < outline.
PointCount(); j++ )
118 pts.push_back( outline.
CPoint( j ) );
125 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"png_polyset" ) ) + wxS(
".png" );
126 BOOST_CHECK( plotter.
SaveFile( tempFile ) );
128 wxImage img( tempFile );
129 BOOST_CHECK( img.IsOk() );
131 wxRemoveFile( tempFile );
160 wxString tempAA = wxFileName::CreateTempFileName( wxS(
"png_aa" ) ) + wxS(
".png" );
161 wxString tempNoAA = wxFileName::CreateTempFileName( wxS(
"png_noaa" ) ) + wxS(
".png" );
163 BOOST_CHECK( plotterAA.
SaveFile( tempAA ) );
164 BOOST_CHECK( plotterNoAA.
SaveFile( tempNoAA ) );
167 BOOST_CHECK( wxFileExists( tempAA ) );
168 BOOST_CHECK( wxFileExists( tempNoAA ) );
170 wxRemoveFile( tempAA );
171 wxRemoveFile( tempNoAA );
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D BLACK
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
PNG rasterization plotter using Cairo graphics library.
virtual void SetCurrentLineWidth(int aWidth, void *aData=nullptr) override
Set the line width for the next drawing.
void SetPixelSize(int aWidth, int aHeight)
Set the output image dimensions in pixels.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T aFill, int aWidth, int aCornerRadius=0) override
bool SaveFile(const wxString &aPath)
Save the rendered image to a PNG file.
void SetResolution(int aDPI)
Set the output resolution in dots per inch.
virtual bool EndPlot() override
void SetAntialias(bool aEnable)
Enable or disable anti-aliasing.
virtual void SetColor(const COLOR4D &aColor) override
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, void *aData=nullptr) override
Draw a polygon ( filled or not ).
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool StartPlot(const wxString &aPageNumber) override
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
@ FILLED_SHAPE
Fill with object color.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(BasicOutput)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I