summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c864049)
raw | patch | inline | side by side (parent: c864049)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Tue, 5 Aug 2008 14:33:46 +0000 (14:33 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Tue, 5 Aug 2008 14:33:46 +0000 (14:33 +0000) |
index d4a9f7062b71572ea11777b34d2f4a28c957c8dd..8bc9eade2815fa61100229d68741289dd219a675 100644 (file)
#include <2geom/path.h>
#include <2geom/transforms.h>
#include <2geom/sbasis-to-bezier.h>
+#include "helper/geom-curves.h"
/** Creates a cairo context to render to the given pixblock on the given area */
cairo_t *
static void
feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix const & trans, Geom::Rect view, bool optimize_stroke)
{
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
Geom::Point end_tr = c.finalPoint() * trans;
if (!optimize_stroke) {
index 325681650e17a36b868230b70a7958b4cddc804c..840f5044a8ad7189776d25fb05d957fa3e61778f 100644 (file)
#include "prefs-utils.h"
#include "inkscape-cairo.h"
#include "helper/geom.h"
+#include "helper/geom-curves.h"
#include "sp-filter.h"
#include "sp-filter-reference.h"
#include "display/nr-filter.h"
if ( (pv.size() == 1) && (pv.front().size() <= 1) ) {
// vector has only one path with only one segment, see if that's a non-curve segment: that would mean no internal region
- Geom::Curve const * c = & pv.front().front();
- if ( dynamic_cast<Geom::LineSegment const*>(c) ||
- dynamic_cast<Geom::HLineSegment const*>(c) ||
- dynamic_cast<Geom::VLineSegment const*>(c) )
+ if ( is_straight_curve(pv.front().front()) )
{
return false;
}
index 2e0f2d59fa528d4556615528a182c1e9b38ad7b4..29c2bdab0eafdb6da0fd42325a48d9e3386a4793 100644 (file)
#include <2geom/bezier-curve.h>\r
#include <2geom/hvlinesegment.h>\r
#include "helper/geom.h"\r
+#include "helper/geom-curves.h"\r
#include <io/sys.h>\r
\r
\r
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit)\r
{\r
//### LINE\r
- if( dynamic_cast<Geom::LineSegment const *> (&*cit) ||\r
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||\r
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )\r
+ if( is_straight_curve(*cit) )\r
{\r
Geom::Point p = cit->finalPoint();\r
out(" LineTo {\n");\r
index 9909d743685fdc7d5961ce805cd9ff2dce746dfe..c1dcec361b0ca28d249dbbf856d8a10cefe98556 100644 (file)
#include <2geom/sbasis-to-bezier.h>
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
+#include "helper/geom-curves.h"
#include "sp-item.h"
using Geom::X;
using Geom::Y;
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
os << "\\lineto(" << c.finalPoint()[X] << "," << c.finalPoint()[Y] << ")\n";
}
index 2a71eabca4ec3f489c06259ded10dd2a20b5050b..02c3626bf9ba9f2255e0b3ee60810cac0f178e23 100644 (file)
#include <2geom/hvlinesegment.h>
#include <2geom/transforms.h>
#include <helper/geom.h>
+#include "helper/geom-curves.h"
#include "extension/system.h"
#include "xml/repr.h"
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit) {
- if( dynamic_cast<Geom::LineSegment const *> (&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if( is_straight_curve(*cit) )
{
double destx = cit->finalPoint()[X];
double desty = cit->finalPoint()[Y];
index 01b8e64b5b3c91732fc4027c83c2fb853b20bbd7..ea746eae72adc4a601bf93294e963b413e61545b 100644 (file)
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
#include "helper/geom.h"
+#include "helper/geom-curves.h"
#include <io/sys.h>
#include <string>
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit)
{
- if( dynamic_cast<Geom::LineSegment const *> (&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if( is_straight_curve(*cit) )
{
Geom::Point p0 = cit->initialPoint();
Geom::Point p1 = cit->finalPoint();
index cad5769758aa45cec80861276b07c070bcfebb6d..6f1405de206e97139820c67f9d6afb9afda6e73a 100644 (file)
#include <2geom/sbasis-to-bezier.h>
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
+#include "helper/geom-curves.h"
/*
using std::atof;
using Geom::X;
using Geom::Y;
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
os << c.finalPoint()[X] << " " << c.finalPoint()[Y] << " lineto\n";
}
diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp
index ac8930412a62cb53c45c241ee477ef3557532850..bf487f65222a5d80e3ab0ee20497d47e4bb10c74 100644 (file)
--- a/src/helper/geom.cpp
+++ b/src/helper/geom.cpp
*/
#include "helper/geom.h"
+#include "helper/geom-curves.h"
#include <typeinfo>
#include <2geom/pathvector.h>
#include <2geom/path.h>
for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_open(); ++cit) {
Geom::Curve const &c = *cit;
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
bbox.expandTo( c.finalPoint() * t );
}
Geom::Coord tolerance, Geom::Rect const *viewbox,
Geom::Point &p0) // pass p0 through as it represents the last endpoint added (the finalPoint of last curve)
{
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
Geom::Point pe = c.finalPoint() * m;
if (bbox) {
output.back().close( pit->closed() );
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) {
- if( dynamic_cast<Geom::CubicBezier const*>(&*cit) ||
- dynamic_cast<Geom::LineSegment const*>(&*cit) ||
- dynamic_cast<Geom::HLineSegment const*>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const*>(&*cit) )
+ if( dynamic_cast<Geom::CubicBezier const*>(&*cit) ||
+ is_straight_curve(*cit) )
{
output.back().append(*cit);
}
index 3a7bd71adf98aefeaf00ea46b6ab07bdf23e63ca..47956031f55fcbaa6670f2de86b78da9f9f63b4a 100644 (file)
#include <2geom/sbasis-to-bezier.h>
#include <2geom/curves.h>
#include "../display/canvas-bpath.h"
+#include "helper/geom-curves.h"
void Path::DashPolyline(float head,float tail,float body,int nbD,float *dashs,bool stPlain,float stOffset)
{
void Path::AddCurve(Geom::Curve const &c)
{
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
LineTo( from_2geom(c.finalPoint()) );
}
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index e641632d910751e93e8b21f0edc79dc70a2873d4..e0e10b6deba7c740fab38769eb3d859766576bb6 100644 (file)
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
#include <2geom/pathvector.h>
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
+#include "helper/geom-curves.h"
#include "svg/svg.h"
#include "xml/repr.h"
for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) {
for(Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) {
// only add curves for straight line segments
- if( dynamic_cast<Geom::LineSegment const *>(&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if( is_straight_curve(*cit) )
{
pts.push_back(std::make_pair(cit->initialPoint() * i2d, cit->finalPoint() * i2d));
}
diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp
index fddc9d1dba7d712e0971d638dfa0056d93d62075..014c68c9b75652ba8af992a904325b2c0daca8db 100644 (file)
--- a/src/sp-polygon.cpp
+++ b/src/sp-polygon.cpp
#include <2geom/pathvector.h>
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
+#include "helper/geom-curves.h"
#include "svg/stringstream.h"
#include "xml/repr.h"
#include "document.h"
for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) {
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) {
- if ( dynamic_cast<Geom::LineSegment const *>(&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if ( is_straight_curve(*cit) )
{
os << cit->finalPoint()[0] << "," << cit->finalPoint()[1] << " ";
} else {