summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 425238c)
raw | patch | inline | side by side (parent: 425238c)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 29 Jun 2008 12:37:25 +0000 (12:37 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 29 Jun 2008 12:37:25 +0000 (12:37 +0000) |
src/display/inkscape-cairo.cpp | patch | blob | history | |
src/helper/geom.cpp | patch | blob | history | |
src/livarot/Path.h | patch | blob | history | |
src/livarot/PathCutting.cpp | patch | blob | history |
index 69e766ce8dd285703f98fedbe5ae04a889f24e49..2ca6cb91d0efb3a7e0e849894cf6a44ccd3294d0 100644 (file)
#include <cairo.h>
+#include <typeinfo>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@@ -159,8 +160,8 @@ feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::
static void
feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix & trans, Geom::Rect view, bool optimize_stroke)
{
- if( typeid(c) == typeid(Geom::LineSegment) ||
- typeid(c) == typeid(Geom::HLineSegment) ||
+ if( typeid(c) == typeid(Geom::LineSegment) ||
+ typeid(c) == typeid(Geom::HLineSegment) ||
typeid(c) == typeid(Geom::VLineSegment) )
{
Geom::Point end_tr = c.finalPoint() * trans;
diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp
index 283e4a3b278ce05c2fee51123622d609aece62e6..9ec21a44da73230332b45d90b9e282f9134af441 100644 (file)
--- a/src/helper/geom.cpp
+++ b/src/helper/geom.cpp
*/\r
\r
#include "helper/geom.h"\r
-\r
+#include <typeinfo>\r
#include <2geom/pathvector.h>\r
#include <2geom/path.h>\r
#include <2geom/transforms.h>\r
\r
// don't loop including closing segment, since that segment can never increase the bbox\r
for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_open(); ++cit) {\r
- Geom::Curve const *c = &*cit;\r
+ Geom::Curve const &c = *cit;\r
\r
- if(Geom::LineSegment const *line_segment = dynamic_cast<Geom::LineSegment const *>(c))\r
+ if( typeid(c) == typeid(Geom::LineSegment) ||\r
+ typeid(c) == typeid(Geom::HLineSegment) ||\r
+ typeid(c) == typeid(Geom::VLineSegment) )\r
{\r
- bbox.expandTo( (*line_segment)[1] * t );\r
+ bbox.expandTo( c.finalPoint() * t );\r
}\r
- else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(c))\r
+ else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(&c))\r
{\r
Geom::Point c0 = (*cubic_bezier)[0] * t;\r
Geom::Point c1 = (*cubic_bezier)[1] * t;\r
}\r
\r
static void\r
-geom_curve_bbox_wind_distance(Geom::Curve const * c, Geom::Matrix const &m,\r
+geom_curve_bbox_wind_distance(Geom::Curve const & c, Geom::Matrix const &m,\r
Geom::Point const &pt,\r
Geom::Rect *bbox, int *wind, Geom::Coord *dist,\r
Geom::Coord tolerance, Geom::Rect const *viewbox,\r
Geom::Point &p0) // pass p0 through as it represents the last endpoint added (the finalPoint of last curve)\r
{\r
- if(Geom::LineSegment const *line_segment = dynamic_cast<Geom::LineSegment const *>(c)) { // TODO: make it work for HLineSegment too! (use finalPoint)\r
- Geom::Point pe = (*line_segment)[1] * m;\r
+ if( typeid(c) == typeid(Geom::LineSegment) ||\r
+ typeid(c) == typeid(Geom::HLineSegment) ||\r
+ typeid(c) == typeid(Geom::VLineSegment) )\r
+ {\r
+ Geom::Point pe = c.finalPoint() * m;\r
if (bbox) {\r
bbox->expandTo(pe);\r
}\r
}\r
p0 = pe;\r
}\r
- else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(c)) {\r
+ else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(&c)) {\r
Geom::Point p1 = (*cubic_bezier)[1] * m;\r
Geom::Point p2 = (*cubic_bezier)[2] * m;\r
Geom::Point p3 = (*cubic_bezier)[3] * m;\r
p0 = p3;\r
} else { \r
//this case handles sbasis as well as all other curve types\r
- Geom::Path sbasis_path = Geom::path_from_sbasis(c->toSBasis(), 0.1);\r
+ Geom::Path sbasis_path = Geom::path_from_sbasis(c.toSBasis(), 0.1);\r
\r
//recurse to convert the new path resulting from the sbasis to svgd\r
for(Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) {\r
- geom_curve_bbox_wind_distance(&(*iter), m, pt, bbox, wind, dist, tolerance, viewbox, p0);\r
+ geom_curve_bbox_wind_distance(*iter, m, pt, bbox, wind, dist, tolerance, viewbox, p0);\r
}\r
}\r
}\r
@@ -436,7 +441,7 @@ pathv_matrix_point_bbox_wind_distance (Geom::PathVector const & pathv, Geom::Mat
\r
// loop including closing segment if path is closed\r
for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_default(); ++cit) {\r
- geom_curve_bbox_wind_distance(&*cit, m, pt, bbox, wind, dist, tolerance, viewbox, p0);\r
+ geom_curve_bbox_wind_distance(*cit, m, pt, bbox, wind, dist, tolerance, viewbox, p0);\r
}\r
}\r
\r
diff --git a/src/livarot/Path.h b/src/livarot/Path.h
index adc26c169e425447e7254b44229980fc43e19ec3..9ba365f6e869b48c75731b090628ecdf592594d9 100644 (file)
--- a/src/livarot/Path.h
+++ b/src/livarot/Path.h
void FlushPendingAddition(Path* dest,PathDescr *lastAddition,PathDescrCubicTo &lastCubic,int lastAD);
private:
- void AddCurve(Geom::Curve const *c);
+ void AddCurve(Geom::Curve const &c);
};
#endif
index 2987536c3e9ee1961146ec79b7ee9aa6eaac1d84..718017851f205c133c22cc674368ced85b83eda9 100644 (file)
#include <cstring>
#include <string>
#include <cstdio>
-
+#include <typeinfo>
#include "Path.h"
#include "style.h"
#include "livarot/path-description.h"
return bpath;
}
-void Path::AddCurve(Geom::Curve const *c)
+void Path::AddCurve(Geom::Curve const &c)
{
- if(Geom::LineSegment const *line_segment = dynamic_cast<Geom::LineSegment const *>(c)) {
- LineTo( NR::Point((*line_segment)[1][0], (*line_segment)[1][1]) );
+ if( typeid(c) == typeid(Geom::LineSegment) ||
+ typeid(c) == typeid(Geom::HLineSegment) ||
+ typeid(c) == typeid(Geom::VLineSegment) )
+ {
+ LineTo( to_2geom(c.finalPoint()) );
}
/*
else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast<Geom::QuadraticBezier const *>(c)) {
...
}
*/
- else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(c)) {
+ else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(&c)) {
Geom::Point tmp = (*cubic_bezier)[3];
Geom::Point tms = 3 * ((*cubic_bezier)[1] - (*cubic_bezier)[0]);
Geom::Point tme = 3 * ((*cubic_bezier)[3] - (*cubic_bezier)[2]);
CubicTo (from_2geom(tmp), from_2geom(tms), from_2geom(tme));
}
- else if(Geom::EllipticalArc const *svg_elliptical_arc = dynamic_cast<Geom::EllipticalArc const *>(c)) {
+ else if(Geom::EllipticalArc const *svg_elliptical_arc = dynamic_cast<Geom::EllipticalArc const *>(&c)) {
ArcTo( from_2geom(svg_elliptical_arc->finalPoint()),
svg_elliptical_arc->ray(0), svg_elliptical_arc->ray(1),
svg_elliptical_arc->rotation_angle(),
svg_elliptical_arc->large_arc_flag(), svg_elliptical_arc->sweep_flag() );
} else {
//this case handles sbasis as well as all other curve types
- Geom::Path sbasis_path = Geom::path_from_sbasis(c->toSBasis(), 0.1);
+ Geom::Path sbasis_path = Geom::path_from_sbasis(c.toSBasis(), 0.1);
//recurse to convert the new path resulting from the sbasis to svgd
for(Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) {
- AddCurve(&*iter);
+ AddCurve(*iter);
}
}
}
MoveTo( from_2geom(pathtr.initialPoint()) );
for(Geom::Path::const_iterator cit = pathtr.begin(); cit != pathtr.end_open(); ++cit) {
- AddCurve(&*cit);
+ AddCurve(*cit);
}
if (pathtr.closed()) {