168 <<
"Eepic_Geom_Object is null";
308 const double &
max)
const
314 result =
max * result;
325 double xpic(
const double & x)
const
395 void zoom(
const double & factor)
462 return "(" + std::to_string(x) +
"," + std::to_string(
y) +
")";
480 output << std::fixed << std::setprecision(6);
485 <<
"\\filltype{" <<
fill_type <<
"}" << std::endl
487 <<
"% leftmost point is " <<
__leftmost.to_string() <<
" --> "
489 <<
"% rightmost point is " <<
__rightmost.to_string() <<
" --> "
491 <<
"% highest point is " <<
__highest.to_string() <<
" --> "
493 <<
"% lowest point is " <<
__lowest.to_string() <<
" --> "
495 <<
"% " <<
list.
size() <<
" geometric objects were put in the plane"
510 output <<
"\\thinlines" << std::endl
517 output <<
"\\end{picture}" << std::endl
535 const double &
get_r()
const {
return r; }
650 output <<
" %% Point " << p.to_string()
651 <<
" %% mapped in this plane to (" << x <<
"," <<
y <<
")"
653 <<
"\\put(" << x <<
"," <<
y <<
"){\\ellipse{" <<
r
654 <<
"}{" <<
r <<
"}}" << std::endl
659# define COMPUTE_SEGMENT_EEPIC_COORDENATES() \
660 const double src_x = x_geom_number_to_eepic(sg.get_src_point().get_x()); \
662 const double src_y = y_geom_number_to_eepic(sg.get_src_point().get_y()); \
664 const double tgt_x = x_geom_number_to_eepic(sg.get_tgt_point().get_x()); \
666 const double tgt_y = y_geom_number_to_eepic(sg.get_tgt_point().get_y());
669# define DRAW_SEGMENT(sg, output) \
670 COMPUTE_SEGMENT_EEPIC_COORDENATES(); \
671 output << " %% Segment from " << sg.get_src_point().to_string() \
672 << " to " << sg.get_tgt_point().to_string() << std::endl \
673 << " %% mapped in this plane to (" << src_x << "," << src_y \
674 << ") to (" << tgt_x << "," << tgt_y << ")" << std::endl \
675 << "\\path(" << src_x << "," << src_y \
676 << ")(" << tgt_x << "," << tgt_y << ")" << std::endl \
691# define PUT_ARROW() \
692 const double arrow_width = arrow_width_in_mm/resolution; \
693 const double arrow_lenght = arrow_lenght_in_mm/resolution; \
695 const double l = sqrt(arrow_width*arrow_width + arrow_lenght*arrow_lenght); \
696 const double tetha = atan2(arrow_width, arrow_lenght); \
697 const double phi = atan( fabs( (tgt_y - src_y)/(tgt_x - src_x) ) ); \
699 double dx1 = l*cos(phi - tetha); \
700 double dy1 = l*sin(phi - tetha); \
702 double dx2 = l*sin(M_PI_2 - (phi + tetha)); \
703 double dy2 = l*cos(M_PI_2 - (phi + tetha)); \
717 output << std::endl \
718 << " % Drawing of arrow's edges at (" << tgt_x \
719 << "," << tgt_y << ")" << std::endl \
720 << "\\path(" << tgt_x << "," << tgt_y << ")(" \
721 << tgt_x + dx1 << "," << tgt_y + dy1 << ")" << std::endl \
722 << "\\path(" << tgt_x << "," << tgt_y << ")(" \
723 << tgt_x + dx2 << "," << tgt_y + dy2 << ")" << std::endl << std::endl;
726# define DRAW_ARROW(sg, output) \
727 DRAW_SEGMENT(sg, output); \
737# define DRAW_DOTTED_SEGMENT(sg, output) \
738 COMPUTE_SEGMENT_EEPIC_COORDENATES(); \
740 output << " %% Dotted Segment from " << sg.get_src_point().to_string() \
741 << " to " << sg.get_tgt_point().to_string() << std::endl \
742 << " %% mapped in this plane to (" << src_x << "," << src_y \
743 << ") to (" << tgt_x << "," << tgt_y << ")" << std::endl \
744 << "\\dottedline{" << dotgap << "}(" << src_x \
745 << "," << src_y << ")(" << tgt_x << "," << tgt_y << ")" << std::endl \
755# define DRAW_DASH_SEGMENT(sg, output) \
756 COMPUTE_SEGMENT_EEPIC_COORDENATES(); \
758 output << " %% Dash Segment from " << sg.get_src_point().to_string() \
759 << " to " << sg.get_tgt_point().to_string() << std::endl \
760 << " %% mapped in this plane to (" << src_x << "," << src_y \
761 << ") to (" << tgt_x << "," << tgt_y << ")" << std::endl \
762 << "\\dashline{" << dotgap << "}(" << src_x \
763 << "," << src_y << ")(" << tgt_x << "," << tgt_y << ")" << std::endl \
773# define DRAW_ARROW_DOTTED_SEGMENT(sg, output) \
774 COMPUTE_SEGMENT_EEPIC_COORDENATES(); \
776 output << " %% Dotted arrow Segment from " << sg.get_src_point().to_string() \
777 << " to " << sg.get_tgt_point().to_string() << std::endl \
778 << " %% mapped in this plane to (" << src_x << "," << src_y \
779 << ") to (" << tgt_x << "," << tgt_y << ")" << std::endl \
780 << "\\dottedline{" << dotgap << "}(" << src_x \
781 << "," << src_y << ")(" << tgt_x << "," << tgt_y << ")" << std::endl \
792# define DRAW_ARROW_DASH_SEGMENT(sg, output) \
793 COMPUTE_SEGMENT_EEPIC_COORDENATES(); \
795 output << " %% Dash arrow Segment from " << sg.get_src_point().to_string() \
796 << " to " << sg.get_tgt_point().to_string() << std::endl \
797 << " %% mapped in this plane to (" << src_x << "," << src_y \
798 << ") to (" << tgt_x << "," << tgt_y << ")" << std::endl \
799 << "\\dashline{" << dotgap << "}(" << src_x \
800 << "," << src_y << ")(" << tgt_x << "," << tgt_y << ")" << std::endl \
823 output <<
" %% Ellipse with center in " << center.to_string()
824 <<
" with horizontal radius of " << e.
get_hradius()
825 <<
" and vertical radius of " << e.
get_vradius() << std::endl
826 <<
" %% mapped in the plane at center (" << x
827 <<
"," <<
y <<
") with horizontal radius of " <<
hd
828 <<
" and vertical radius of " <<
vd << std::endl
829 <<
"\\put(" << x <<
"," <<
y <<
"){\\ellipse{" <<
hd
830 <<
"}{" <<
vd <<
"}}" << std::endl
843 template <
class Poly>
848 for (
typename Poly::Segment_Iterator it(poly); it.has_curr(); it.next_ne())
854 template <
class Poly>
857 output <<
" % Drawing of polygon of " << poly.size()
858 <<
" sides" << std::endl
861 for (
typename Poly::Vertex_Iterator it(poly); it.has_curr(); it.next_ne())
864 if (poly.is_closed())
869 template <
class Poly>
872 output <<
" % Drawing of dotted line Polygon" << std::endl
873 <<
"\\shade\\dottedline{" <<
dotgap <<
"}";
875 for (
typename Poly::Vertex_Iterator it(poly); it.has_curr(); it.next_ne())
878 if (poly.is_closed())
883 template <
class Poly>
886 for (
typename Poly::Vertex_Iterator it(poly); it.has_curr(); it.next_ne())
888 Vertex & vertex = it.get_current_vertex();
902 template <
class Poly>
905 for (
typename Poly::Segment_Iterator it(poly); it.has_curr(); it.next_ne())
907 const Segment & sg = it.get_current_segment();
913 template <
class Poly>
927 const std::string str = p.to_string();
929 output <<
" %% Text Point " << str
930 <<
" %% mapped in this plane to (" << x <<
"," <<
y <<
")"
932 <<
"\\put(" << x <<
"," <<
y <<
"){\\texttt{" << str
939 template <
class Poly>
942 for (
typename Poly::Vertex_Iterator it(poly); it.has_curr(); it.next_ne())
948 template <
class Poly>
953 for (
typename Poly::Vertex_Iterator it(poly);
954 it.has_curr(); it.next_ne(), ++n)
956 Vertex & vertex = it.get_current_vertex();
962 output <<
" %% Poligon Vertex Number " << n
963 <<
" %% mapped in this plane to (" << x <<
"," <<
y <<
")"
965 <<
"\\put(" << x <<
"," <<
y <<
"){$" << n <<
"$}" << std::endl
971 template <
class Poly>
974 output <<
" % Drawing spline of " << poly.size()
975 <<
" points" << std::endl
978 for (
typename Poly::Vertex_Iterator it(poly); it.has_curr(); it.next_ne())
981 if (poly.is_closed())
986 template <
class Poly>
989 output <<
" % Drawing dash curve of " << poly.size()
990 <<
" points" << std::endl
993 for (
typename Poly::Vertex_Iterator it(poly); it.has_curr(); it.next_ne())
996 if (poly.is_closed())
1001 template <
class Poly>
1012 template <
class Poly>
1035 output <<
"% std::string at " << p.to_string() << std::endl
1036 <<
"% mapped to the plane at (" << x <<
"," <<
y <<
")" << std::endl
1037 <<
"\\put(" << x <<
"," <<
y <<
"){\\texttt{"
1039 <<
"}}" << std::endl
1054# define DEFINE_EEPIC_COPY_CTOR(Type) \
1055 Eepic_##Type(const Type & o) : Eepic_Geom_Object(new Type(o), true) { }
1059# define DEFINE_EEPIC_COMMON_METHODS(Type) \
1060 friend void put_in_plane(Eepic_Plane & plane, const Type & geom_obj); \
1062 ~Eepic_##Type() { } \
1064 Point highest_point() const override \
1066 return static_cast<const Type*>(geom_object_ptr)->highest_point(); \
1069 Point lowest_point() const override \
1071 return static_cast<const Type*>(geom_object_ptr)->lowest_point(); \
1074 Point leftmost_point() const override \
1076 return static_cast<const Type*>(geom_object_ptr)->leftmost_point(); \
1079 Point rightmost_point() const override \
1081 return static_cast<const Type*>(geom_object_ptr)->rightmost_point(); \
1084 Eepic_Geom_Object * clone() const override \
1086 return new Eepic_##Type(static_cast<const Type&>(*geom_object_ptr)); \
1089 void draw(Eepic_Plane * plane, std::ostream & output) const override;
1093# define DEFINE_EEPIC_COMMON_WITH_COPY_CTOR(Type) \
1094 DEFINE_EEPIC_COPY_CTOR(Type) \
1095 DEFINE_EEPIC_COMMON_METHODS(Type)
1099# define DEFINE_EEPIC_COMMON_WITHOUT_COPY_CTOR(Type) \
1100 DEFINE_EEPIC_COMMON_METHODS(Type) \
1101 Eepic_##Type(const Type &);
1105# define DEFINE_PUT_IN_PLANE(Type) \
1106 extern void put_in_plane(Eepic_Plane & plane, const Type & geom_obj)
1109# define IMPL_PUT_IN_PLANE(Type) \
1110 void put_in_plane(Eepic_Plane & plane, const Type & geom_obj) \
1112 Eepic_##Type eepic_obj(geom_obj); \
1114 plane.put(eepic_obj); \
1125# define DEFINE_EEPIC_CLASS(Type) \
1126 class Eepic_##Type : public Eepic_Geom_Object \
1128 DEFINE_EEPIC_COMMON_WITH_COPY_CTOR(Type) \
1131 DEFINE_PUT_IN_PLANE(Type)
1137# define DEFINE_EEPIC_CLASS_AND_MEMBERS(Type, ...) \
1138 class Eepic_##Type : public Eepic_Geom_Object \
1141 DEFINE_EEPIC_COMMON_WITHOUT_COPY_CTOR(Type) \
1144 DEFINE_PUT_IN_PLANE(Type)
1161# define DEFINE_CLASS_DERIVATED_FROM_SEGMENT(Name) \
1162 struct Name : public Segment \
1166 Name(const Segment & s) : Segment(s) \
1170 Name(const Point & __src, const Point & __tgt) \
1171 : Segment(__src, __tgt) \
1176 Name(const Point & __src, \
1177 const Geom_Number & m, \
1178 const Geom_Number & d) \
1179 : Segment(__src, m, d) \
1187# define DEFINE_EEPIC_SEGMENT_CLASS(Name) \
1188 DEFINE_CLASS_DERIVATED_FROM_SEGMENT(Name) \
1189 DEFINE_EEPIC_CLASS(Name);
1194# define DEFINE_EEPIC_SEGMENT_CLASS_AND_MEMBERS(Name, ...) \
1195 DEFINE_CLASS_DERIVATED_FROM_SEGMENT(Name) \
1196 DEFINE_EEPIC_CLASS_AND_MEMBERS(Name, __VA_ARGS__);
1233# define DEFINE_CLASS_DERIVATED_FROM_ELLIPSE(Name) \
1234 struct Name : public Ellipse \
1238 Name(const Ellipse & p) : Ellipse(p) \
1243 Name(const Point & center, \
1244 const Geom_Number & hr, \
1245 const Geom_Number & vr) \
1246 : Ellipse(center, hr, vr) \
1264# define DEFINE_CLASS_DERIVATED_FROM_TEXT(Name) \
1265 struct Name : public Text \
1269 Name(const Text & t) : Text(t) \
1274 Name(const Point & p, const std::string & str) \
1308# define DEFINE_CLASS_DERIVATED_FROM_POLYGON(Name) \
1309 struct Name : public Polygon \
1313 Name(const Polygon & p) : Polygon(p) \
1320# define DEFINE_EEPIC_POLYGON(Name) \
1321 DEFINE_CLASS_DERIVATED_FROM_POLYGON(Name); \
1322 DEFINE_EEPIC_CLASS(Name);
1437# define DEFINE_CLASS_DERIVATED_FROM_REGULAR_POLYGON(Name) \
1438 struct Name : public Regular_Polygon \
1442 Name(const Regular_Polygon & p) : Regular_Polygon(p) \
1447 Name(const Point & c, \
1448 const double & side_sz, \
1450 const double & ang = 0) \
1451 : Regular_Polygon(c, side_sz, n, ang) \
1458# define DEFINE_EEPIC_REGULAR_POLYGON(Name) \
1459 DEFINE_CLASS_DERIVATED_FROM_REGULAR_POLYGON(Name); \
1460 DEFINE_EEPIC_CLASS(Name);
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
#define ah_logic_error()
Throws std::logic_error unconditionally.
bool has_curr() const noexcept
Return true if the iterator has current item.
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
T & get_curr() const
Return the current item; throw overflow_error if there is no current item.
void next()
Move the iterator one item forward.
Dynamic doubly linked list with O(1) size and bidirectional access.
const size_t & size() const noexcept
Return the number of elements (constant time)
T & append(const T &item)
Append a copied item at the end of the list.
T remove_first_ne() noexcept
Remove the first item of the list; return a copy of removed item.
Abstract base class for EEPIC-drawable geometric objects.
virtual Eepic_Geom_Object * clone() const =0
Create a polymorphic copy of this object.
const Geom_Object *const geom_object_ptr
Pointer to the wrapped geometric object.
virtual ~Eepic_Geom_Object()
Virtual destructor.
Eepic_Geom_Object(Geom_Object *ptr, const bool &__to_delete=false)
Construct an EEPIC wrapper for a geometric object.
Eepic_Geom_Object(const Eepic_Geom_Object &)
virtual void draw(Eepic_Plane *plane, std::ostream &output) const
Generate EEPIC code for this object.
virtual Point lowest_point() const =0
Get the lowest point (minimum y-coordinate) of this object.
virtual Point highest_point() const =0
Get the highest point (maximum y-coordinate) of this object.
bool to_delete
Flag indicating ownership of geom_object_ptr.
virtual Point rightmost_point() const =0
Get the rightmost point (maximum x-coordinate) of this object.
virtual Point leftmost_point() const =0
Get the leftmost point (minimum x-coordinate) of this object.
2D canvas for generating EEPIC/LaTeX picture environments.
static const double dotgap
Gap between dots in dotted lines.
void draw_dotted_segment(const Segment &sg, std::ostream &output)
Emit EEPIC code to draw dotted segment sg.
const double & get_height() const
Picture height (in EEPIC units).
Geom_Number geom_height
Height from lowest to highest point.
std::string fill_type
Fill type for shapes (e.g., "black")
void draw_arrow_dash_segment(const Segment &sg, std::ostream &output)
Emit EEPIC code to draw dashed segment sg with arrow head.
Point __lowest
Point with minimum y-coordinate.
Point __leftmost
Point with minimum x-coordinate.
Eepic_Plane(const double &__wide, const double &__height, const double &__xoffset=0.0, const double &__yoffset=0.0)
Construct a plane with a fixed picture frame.
void zoom(const double &factor)
Scale the EEPIC plane in real points (zoom in/out).
void set_fill_type(const std::string &ftype)
Set the fill type used by LaTeX eepic (e.g., "black").
void draw_point_text(const Point &p, std::ostream &output)
double real_wide
Actual width after scaling.
void draw_segment(const Segment &sg, std::ostream &output)
Emit EEPIC code to draw segment sg.
double get_shade_thickness() const
Return the current shading thickness.
Geom_Number geom_y_min
Minimum y value in geometric coordinates.
double y_geom_number_to_eepic(const Geom_Number &y) const
Convert a geometric y coordinate into plane y coordinate.
void compute_geom_plane(const bool &squarize)
Compute extreme coordinates and derive width/height of all objects.
DynDlist< Eepic_Geom_Object * > list
List of geometric objects.
double x_min
Minimum x value in plane coordinates.
const double & get_yoffset() const
Y offset of the LaTeX picture environment.
double r
Actual radius in real points for drawing a point.
void draw_dash_spline(Poly &poly, std::ostream &output)
void set_resolution(const double &res)
Set the output resolution in millimeters (unitlength = res mm).
double y_min
Minimum y value in plane coordinates.
double resolution
Resolution in millimeters (default: 0.05mm)
double height
Height in resolution points.
Point __rightmost
Point with maximum x-coordinate.
bool with_cartesian_axis
Flag to draw Cartesian axes.
static const double arrow_lenght_in_mm
Point __highest
Point with maximum y-coordinate.
static const double normal_thickness
Default line thickness.
const double & get_wide() const
Plane accessors.
Geom_Number geom_wide
Width from leftmost to rightmost point.
double wide
Width in resolution points.
const double & get_xoffset() const
X offset of the LaTeX picture environment.
double ypic(const double &y) const
Normalize to y-axis origin.
static const double default_r
Default radius for drawing points (also used for text height)
void compute_extreme_points()
Linear scan over all objects to compute extreme points.
double get_dotgap() const
Return the dot gap used for dotted/dashed lines.
void draw_ellipse(const Ellipse &e, std::ostream &output)
Emit EEPIC code to draw ellipse e.
void draw_arrow_extreme(const Segment &sg, std::ostream &output)
static const double default_shade_thickness
Default shading thickness.
double xoffset
Additional horizontal margin.
double h_geom_number_to_eepic(const Geom_Number &x) const
Convert a geometric x proportion into plane units using wide.
const double & get_resolution() const
Return the current output resolution in millimeters.
void draw_text(const Text &t, std::ostream &output, const double &hfactor, const double &vfactor)
void draw_dots_from_polygon(Poly &poly, std::ostream &output)
void set_shade_thickness(const double &__thickness)
Set the thickness used for shaded primitives.
void(Eepic_Plane::* Draw_Segment_Fct)(const Segment &poly, std::ostream &output)
void draw_points_text_in_polygon(Poly &poly, std::ostream &output)
void draw_dash_spline_arrow(Poly &poly, std::ostream &output)
double real_height
Actual height after scaling.
void draw_closed_polygon(Poly &poly, std::ostream &output)
void draw_polygon(Poly &poly, std::ostream &output, Draw_Segment_Fct draw_sg_fct)
void draw_closed_polygon_with_arrows(Poly &poly, std::ostream &output)
double x_geom_number_to_eepic(const Geom_Number &x) const
Convert a geometric x coordinate into plane x coordinate.
const Point & highest() const
std::string shade_type
Shading type for segments.
void put_cartesian_axis()
Enable drawing Cartesian axes when calling draw().
void draw_arrow(const Segment &sg, std::ostream &output)
Emit EEPIC code to draw segment sg with an arrow head.
void draw_vertex_numbers_in_polygon(Poly &poly, std::ostream &output)
double shade_thickness
Current shading thickness.
double yoffset
Additional vertical margin.
const double & get_r() const
Radius used to draw points (also used as text baseline offset).
void draw_arrows_in_polygon(Poly &poly, std::ostream &output)
double v_geom_number_to_eepic(const Geom_Number &y) const
Convert a geometric y proportion into plane units using height.
Geom_Number geom_x_min
Minimum x value in geometric coordinates.
static const double arrow_width_in_mm
void put(const Eepic_Geom_Object &__eepic_geom_obj)
Design note: why Eepic_Plane stores Eepic_Geom_Object wrappers.
const Point & lowest() const
const Point & rightmost() const
void draw_spline(Poly &poly, std::ostream &output)
void draw_point(const Point &p, std::ostream &output)
EEPIC "primitive drawing" methods.
double geom_number_to_plane(const Geom_Number &p, const Geom_Number &geom_max, const double &max) const
Rescales a coordinate value p from a geometric scale geom_max into the plane scale max.
void draw_dotted_closed_polygon(Poly &poly, std::ostream &output)
void draw(std::ostream &output, const bool &squarize=true)
Emits a complete LaTeX picture environment containing the geometric objects.
~Eepic_Plane()
Destructor: deletes all stored Eepic_Geom_Object clones.
void draw_arrow_dotted_segment(const Segment &sg, std::ostream &output)
Emit EEPIC code to draw dotted segment sg with arrow head.
void draw_dash_segment(const Segment &sg, std::ostream &output)
Emit EEPIC code to draw dashed segment sg.
void draw_spline_arrow(Poly &poly, std::ostream &output)
void draw_cartesian_axis(std::ostream &output)
const Point & leftmost() const
double xpic(const double &x) const
Points must be normalized to the plane size (in picture coordinates).
std::string point_string(const Point &p)
Given point p, returns "(x,y)" in normalized plane coordinates.
const Geom_Number & get_vradius() const
const Geom_Number & get_hradius() const
const Point & get_center() const
A general (irregular) 2D polygon defined by a sequence of vertices.
A regular polygon defined by center, side length, and vertex count.
Fundamental segment defined by two points.
static const double font_width_in_points
const Point & get_point() const
const std::string & get_str() const
const size_t & len() const
static const double font_height_in_points
A vertex in a polygon's doubly-linked vertex list.
#define DRAW_DOTTED_SEGMENT(sg, output)
#define DEFINE_EEPIC_CLASS(Type)
Fundamental macro to declare a class derived from Eepic_Geom_Object.
#define DEFINE_EEPIC_REGULAR_POLYGON(Name)
#define DRAW_ARROW(sg, output)
bool tiny_keys
Global flag to enable tiny font size for keys/labels.
#define DRAW_ARROW_DOTTED_SEGMENT(sg, output)
#define DEFINE_EEPIC_SEGMENT_CLASS(Name)
#define DEFINE_CLASS_DERIVATED_FROM_ELLIPSE(Name)
#define DRAW_DASH_SEGMENT(sg, output)
#define COMPUTE_SEGMENT_EEPIC_COORDENATES()
#define DRAW_ARROW_DASH_SEGMENT(sg, output)
#define DEFINE_EEPIC_POLYGON(Name)
#define DEFINE_CLASS_DERIVATED_FROM_TEXT(Name)
Text wrappers.
#define DRAW_SEGMENT(sg, output)
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_max_function > > max(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
DynList< T > maps(const C &c, Op op)
Classic map operation.
2D point and geometric utilities.
double geom_number_to_double(const Geom_Number &n)
2D polygon representation and geometric operations.
Segment-drawing variants (types).
Dynamic doubly linked list implementation.
Comprehensive sorting algorithms and search utilities for Aleph-w.