20#include <boost/test/unit_test.hpp>
22#include <wx/filename.h>
39 BOOST_CHECK( plotter.
StartPlot( wxEmptyString ) );
40 BOOST_CHECK( plotter.
EndPlot() );
42 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"png_test" ) ) + wxS(
".png" );
43 BOOST_CHECK( plotter.
SaveFile( tempFile ) );
46 BOOST_CHECK( wxFileExists( tempFile ) );
49 wxImage img( tempFile );
50 BOOST_CHECK( img.IsOk() );
54 wxRemoveFile( tempFile );
70 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"png_rect" ) ) + wxS(
".png" );
71 BOOST_CHECK( plotter.
SaveFile( tempFile ) );
73 wxImage img( tempFile );
74 BOOST_CHECK( img.IsOk() );
77 unsigned char r = img.GetRed( 50, 50 );
78 unsigned char g = img.GetGreen( 50, 50 );
79 unsigned char b = img.GetBlue( 50, 50 );
80 BOOST_CHECK_GT( r, 200 );
81 BOOST_CHECK_LT( g, 50 );
82 BOOST_CHECK_LT( b, 50 );
84 wxRemoveFile( tempFile );
112 std::vector<VECTOR2I> pts;
114 for(
int j = 0; j < outline.
PointCount(); j++ )
115 pts.push_back( outline.
CPoint( j ) );
122 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"png_polyset" ) ) + wxS(
".png" );
123 BOOST_CHECK( plotter.
SaveFile( tempFile ) );
125 wxImage img( tempFile );
126 BOOST_CHECK( img.IsOk() );
128 wxRemoveFile( tempFile );
157 wxString tempAA = wxFileName::CreateTempFileName( wxS(
"png_aa" ) ) + wxS(
".png" );
158 wxString tempNoAA = wxFileName::CreateTempFileName( wxS(
"png_noaa" ) ) + wxS(
".png" );
160 BOOST_CHECK( plotterAA.
SaveFile( tempAA ) );
161 BOOST_CHECK( plotterNoAA.
SaveFile( tempNoAA ) );
164 BOOST_CHECK( wxFileExists( tempAA ) );
165 BOOST_CHECK( wxFileExists( tempNoAA ) );
167 wxRemoveFile( tempAA );
168 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)
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
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