53#include <gtest/gtest.h>
69 return std::abs(a - b) <
tol;
91 EXPECT_EQ(plane_default->get_wide(), 500);
92 EXPECT_EQ(plane_default->get_height(), 300);
93 EXPECT_EQ(plane_default->get_xoffset(), 0);
94 EXPECT_EQ(plane_default->get_yoffset(), 0);
99 EXPECT_EQ(plane_with_offset->get_wide(), 500);
100 EXPECT_EQ(plane_with_offset->get_height(), 300);
101 EXPECT_EQ(plane_with_offset->get_xoffset(), 10);
102 EXPECT_EQ(plane_with_offset->get_yoffset(), 20);
107 plane_default->set_resolution(0.1);
108 EXPECT_EQ(plane_default->get_resolution(), 0.1);
110 plane_default->set_resolution(0.05);
111 EXPECT_EQ(plane_default->get_resolution(), 0.05);
116 double original = plane_default->get_shade_thickness();
117 plane_default->set_shade_thickness(2.0);
118 EXPECT_EQ(plane_default->get_shade_thickness(), 2.0);
120 plane_default->set_shade_thickness(
original);
156 plane = std::make_unique<Eepic_Plane>(500, 500);
171 std::ostringstream
output;
174 std::string result =
output.str();
175 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
176 EXPECT_TRUE(result.find(
"\\end{picture}") != std::string::npos);
187 std::ostringstream
output;
190 std::string result =
output.str();
191 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
192 EXPECT_TRUE(result.find(
"\\end{picture}") != std::string::npos);
202 std::ostringstream
output;
205 std::string result =
output.str();
206 EXPECT_TRUE(result.find(
"\\path") != std::string::npos);
216 std::ostringstream
output;
219 std::string result =
output.str();
221 EXPECT_TRUE(result.find(
"\\path") != std::string::npos);
226 Point center(50, 50);
227 Ellipse ellipse(center, 20, 10);
230 std::ostringstream
output;
233 std::string result =
output.str();
234 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
248 std::ostringstream
output;
251 std::string result =
output.str();
252 EXPECT_TRUE(result.find(
"\\path") != std::string::npos);
264 std::ostringstream
output;
267 std::string result =
output.str();
268 EXPECT_TRUE(result.find(
"\\path") != std::string::npos);
280 std::ostringstream
output;
283 std::string result =
output.str();
284 EXPECT_TRUE(result.find(
"Hello") != std::string::npos);
298 std::ostringstream
output;
301 std::string result =
output.str();
303 EXPECT_TRUE(result.find(
"3 geometric objects were put in the plane") !=
316 plane = std::make_unique<Eepic_Plane>(500, 500);
329 std::ostringstream
output;
346 std::ostringstream
output;
363 std::ostringstream
output;
381 plane = std::make_unique<Eepic_Plane>(500, 500);
383 p2 = Point(100, 100);
395 std::ostringstream
output;
398 std::string result =
output.str();
399 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
407 std::ostringstream
output;
410 std::string result =
output.str();
411 EXPECT_TRUE(result.find(
"\\dottedline") != std::string::npos);
419 std::ostringstream
output;
422 std::string result =
output.str();
423 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
431 std::ostringstream
output;
434 std::string result =
output.str();
435 EXPECT_TRUE(result.find(
"\\dottedline") != std::string::npos);
437 EXPECT_TRUE(result.find(
"arrow's edges") != std::string::npos);
445 std::ostringstream
output;
448 std::string result =
output.str();
449 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
461 plane = std::make_unique<Eepic_Plane>(500, 500);
475 std::ostringstream
output;
478 std::string result =
output.str();
492 std::ostringstream
output;
495 std::string result =
output.str();
504 Point p2(100, 50.001);
508 std::ostringstream
output;
511 std::string result =
output.str();
528 std::ostringstream
output;
532 std::string result =
output.str();
542 Point p2(50.001, 100);
546 std::ostringstream
output;
559 plane = std::make_unique<Eepic_Plane>(500, 500);
578 std::ostringstream
output;
581 std::string result =
output.str();
582 EXPECT_TRUE(result.find(
"\\shade") != std::string::npos);
590 std::ostringstream
output;
593 std::string result =
output.str();
594 EXPECT_TRUE(result.find(
"\\dottedline") != std::string::npos);
602 std::ostringstream
output;
605 std::string result =
output.str();
606 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
614 std::ostringstream
output;
617 std::string result =
output.str();
619 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
627 std::ostringstream
output;
630 std::string result =
output.str();
631 EXPECT_TRUE(result.find(
"\\spline") != std::string::npos);
639 std::ostringstream
output;
642 std::string result =
output.str();
643 EXPECT_TRUE(result.find(
"\\spline") != std::string::npos);
655 plane = std::make_unique<Eepic_Plane>(500, 500);
665 Ellipse ellipse(center, 20, 10);
668 std::ostringstream
output;
671 std::string result =
output.str();
672 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
680 std::ostringstream
output;
683 std::string result =
output.str();
684 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
685 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
693 std::ostringstream
output;
696 std::string result =
output.str();
697 EXPECT_TRUE(result.find(
"\\shade") != std::string::npos);
703 Ellipse circle(center, 15, 15);
706 std::ostringstream
output;
709 std::string result =
output.str();
710 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
722 plane = std::make_unique<Eepic_Plane>(500, 500);
737 std::ostringstream
output;
740 std::string result =
output.str();
741 EXPECT_TRUE(result.find(
"LeftAligned") != std::string::npos);
749 std::ostringstream
output;
752 std::string result =
output.str();
753 EXPECT_TRUE(result.find(
"RightAligned") != std::string::npos);
761 std::ostringstream
output;
764 std::string result =
output.str();
765 EXPECT_TRUE(result.find(
"Centered") != std::string::npos);
774 std::ostringstream
output;
777 std::string result =
output.str();
778 EXPECT_TRUE(result.find(
"Test$LaTeX$") != std::string::npos);
790 plane = std::make_unique<Eepic_Plane>(500, 500);
804 std::ostringstream
output;
807 std::string result =
output.str();
808 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
817 std::ostringstream
output;
820 std::string result =
output.str();
821 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
830 std::ostringstream
output;
833 std::string result =
output.str();
834 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
846 plane = std::make_unique<Eepic_Plane>(500, 500);
858 plane->set_resolution(0.1);
860 std::ostringstream
output;
863 std::string result =
output.str();
864 EXPECT_TRUE(result.find(
"\\setlength{\\unitlength}{0.1") != std::string::npos);
873 plane->set_fill_type(
"gray");
875 std::ostringstream
output;
878 std::string result =
output.str();
879 EXPECT_TRUE(result.find(
"\\filltype{gray}") != std::string::npos);
888 std::ostringstream
output;
891 std::string result =
output.str();
894 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
895 EXPECT_TRUE(result.find(
"\\end{picture}") != std::string::npos);
898 size_t begin_pos = result.find(
"\\begin{picture}");
899 size_t end_pos = result.find(
"\\end{picture}");
910 std::ostringstream
output;
913 std::string result =
output.str();
915 EXPECT_TRUE(result.find(
"\\thinlines") != std::string::npos);
925 std::ostringstream
output;
928 std::string result =
output.str();
931 EXPECT_TRUE(result.find(
"leftmost point") != std::string::npos);
932 EXPECT_TRUE(result.find(
"rightmost point") != std::string::npos);
933 EXPECT_TRUE(result.find(
"highest point") != std::string::npos);
934 EXPECT_TRUE(result.find(
"lowest point") != std::string::npos);
946 plane = std::make_unique<Eepic_Plane>(500, 300);
959 std::ostringstream
output;
960 plane->draw(
output,
true);
962 std::string result =
output.str();
963 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
973 std::ostringstream
output;
974 plane->draw(
output,
false);
976 std::string result =
output.str();
977 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
989 plane = std::make_unique<Eepic_Plane>(500, 500);
1001 plane->put_cartesian_axis();
1003 std::ostringstream
output;
1007 std::string result =
output.str();
1008 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
1020 plane = std::make_unique<Eepic_Plane>(500, 500);
1029 std::ostringstream
dummy;
1039 std::string str = plane->point_string(p);
1050 double result = plane->h_geom_number_to_eepic(x);
1059 double result = plane->v_geom_number_to_eepic(
y);
1079 std::ostringstream
output;
1097 std::ostringstream
output;
1108 Point center(50, 50);
1109 Ellipse ellipse(center, 20, 10);
1112 std::ostringstream
output;
1131 plane = std::make_unique<Eepic_Plane>(500, 500);
1133 p2 = Point(100, 100);
1145 std::ostringstream
output;
1148 std::string result =
output.str();
1149 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1150 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
1158 std::ostringstream
output;
1161 std::string result =
output.str();
1162 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1170 std::ostringstream
output;
1173 std::string result =
output.str();
1174 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1175 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
1187 plane = std::make_unique<Eepic_Plane>(500, 500);
1205 std::ostringstream
output;
1208 std::string result =
output.str();
1209 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1210 EXPECT_TRUE(result.find(
"\\spline") != std::string::npos);
1218 std::ostringstream
output;
1221 std::string result =
output.str();
1222 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1230 std::ostringstream
output;
1233 std::string result =
output.str();
1234 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1235 EXPECT_TRUE(result.find(
"\\shade") != std::string::npos);
1250 plane = std::make_unique<Eepic_Plane>(500, 500);
1252 Point p1(0.001, 0.001);
1253 Point p2(0.002, 0.002);
1257 std::ostringstream
output;
1263 plane = std::make_unique<Eepic_Plane>(500, 500);
1265 Point p1(1000000, 1000000);
1266 Point p2(1000100, 1000100);
1270 std::ostringstream
output;
1276 plane = std::make_unique<Eepic_Plane>(500, 500);
1278 Point p1(-100, -100);
1283 std::ostringstream
output;
1290 plane = std::make_unique<Eepic_Plane>(500, 500);
1296 std::ostringstream
output;
1304 plane = std::make_unique<Eepic_Plane>(500, 500);
1312 std::ostringstream
output;
1319 plane = std::make_unique<Eepic_Plane>(500, 500);
1328 std::ostringstream
output;
1342 for (
int i = 0; i < 100; ++i)
1348 std::ostringstream
output;
1367 for (
int i = 0; i < 10; ++i)
1369 std::ostringstream
output;
1385 for (
int i = 0; i < 10; ++i)
1387 std::ostringstream
output;
1429 std::ostringstream
output;
1432 std::string result =
output.str();
1435 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
1436 EXPECT_TRUE(result.find(
"\\end{picture}") != std::string::npos);
1437 EXPECT_TRUE(result.find(
"Title") != std::string::npos);
1438 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
1441 EXPECT_TRUE(result.find(
"geometric objects were put in the plane") !=
1475 std::ostringstream
output;
1478 std::string result =
output.str();
1479 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
1480 EXPECT_TRUE(result.find(
"12 geometric objects were put in the plane") !=
1490 ::testing::InitGoogleTest(&
argc,
argv);
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane_with_offset
std::unique_ptr< Eepic_Plane > plane_default
std::unique_ptr< Eepic_Plane > plane
2D canvas for generating EEPIC/LaTeX picture environments.
const double & get_height() const
Picture height (in EEPIC units).
void zoom(const double &factor)
Scale the EEPIC plane in real points (zoom in/out).
const double & get_wide() const
Plane accessors.
const Point & highest() const
const Point & lowest() const
const Point & rightmost() const
void draw(std::ostream &output, const bool &squarize=true)
Emits a complete LaTeX picture environment containing the geometric objects.
const Point & leftmost() const
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
Rectangular point in the plane.
const Geom_Number & get_y() const
Returns y value.
const Geom_Number & get_x() const
Returns x value.
std::unique_ptr< Eepic_Plane > plane
A general (irregular) 2D polygon defined by a sequence of vertices.
void close()
Close the polygon.
void add_vertex(const Point &point)
Add a vertex to the polygon.
std::unique_ptr< Eepic_Plane > plane
A regular polygon defined by center, side length, and vertex count.
std::unique_ptr< Eepic_Plane > plane
Fundamental segment defined by two points.
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
void put_in_plane(Eepic_Plane &plane, const Point &geom_obj)
EEPIC/LaTeX geometric drawing utilities.
bool approx_equal(double a, double b, double tol=EPSILON)
TEST_F(EepicPlaneTest, DefaultConstruction)
bool tiny_keys
Global flag to enable tiny font size for keys/labels.
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Segment-drawing variants (types).