summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a5e13cc)
raw | patch | inline | side by side (parent: a5e13cc)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Wed, 13 Aug 2008 19:06:18 +0000 (19:06 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Wed, 13 Aug 2008 19:06:18 +0000 (19:06 +0000) |
13 files changed:
index 8e8c4b0667049bae251dfc2997a7cdc04540e0ff..c982a8c89d527856a8ad24835d257aa32eeb8533 100644 (file)
if (cc->active_conn == item)
{
// Just adjust handle positions.
- Geom::Point startpt = curve->first_point() * i2d;
+ Geom::Point startpt = *(curve->first_point()) * i2d;
sp_knot_set_position(cc->endpt_handle[0], startpt, 0);
- Geom::Point endpt = curve->last_point() * i2d;
+ Geom::Point endpt = *(curve->last_point()) * i2d;
sp_knot_set_position(cc->endpt_handle[1], endpt, 0);
return;
G_CALLBACK(endpt_handler), cc);
}
- Geom::Point startpt = curve->first_point() * i2d;
+ Geom::Point startpt = *(curve->first_point()) * i2d;
sp_knot_set_position(cc->endpt_handle[0], startpt, 0);
- Geom::Point endpt = curve->last_point() * i2d;
+ Geom::Point endpt = *(curve->last_point()) * i2d;
sp_knot_set_position(cc->endpt_handle[1], endpt, 0);
sp_knot_show(cc->endpt_handle[0]);
index 56b49ff4ceeee1be66e05cc54e593e6ba039c521..c0b0e900b1371375aff2b24d2db722724e3ebd2b 100644 (file)
--- a/src/display/curve-test.h
+++ b/src/display/curve-test.h
void testFirstPoint()
{
- TS_ASSERT_EQUALS(SPCurve(Geom::PathVector(1, path1)).first_point() , Geom::Point(0,0));
- TS_ASSERT_EQUALS(SPCurve(Geom::PathVector(1, path2)).first_point() , Geom::Point(2,0));
- TS_ASSERT_EQUALS(SPCurve(Geom::PathVector(1, path3)).first_point() , Geom::Point(4,0));
- TS_ASSERT_EQUALS(SPCurve(Geom::PathVector(1, path4)).first_point() , Geom::Point(3,5));
+ TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path1)).first_point()) , Geom::Point(0,0));
+ TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path2)).first_point()) , Geom::Point(2,0));
+ TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path3)).first_point()) , Geom::Point(4,0));
+ TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path4)).first_point()) , Geom::Point(3,5));
Geom::PathVector pv;
+ TS_ASSERT(!SPCurve(pv).first_point());
pv.push_back(path1);
pv.push_back(path2);
pv.push_back(path3);
- TS_ASSERT_EQUALS(SPCurve(pv).first_point() , Geom::Point(0,0));
+ TS_ASSERT_EQUALS(*(SPCurve(pv).first_point()) , Geom::Point(0,0));
pv.insert(pv.begin(), path4);
- TS_ASSERT_EQUALS(SPCurve(pv).first_point() , Geom::Point(3,5));
+ TS_ASSERT_EQUALS(*(SPCurve(pv).first_point()) , Geom::Point(3,5));
}
void testLastPoint()
{
- TS_ASSERT_EQUALS(SPCurve(Geom::PathVector(1, path1)).last_point() , Geom::Point(0,0));
- TS_ASSERT_EQUALS(SPCurve(Geom::PathVector(1, path2)).last_point() , Geom::Point(2,0));
- TS_ASSERT_EQUALS(SPCurve(Geom::PathVector(1, path3)).last_point() , Geom::Point(8,4));
- TS_ASSERT_EQUALS(SPCurve(Geom::PathVector(1, path4)).last_point() , Geom::Point(3,5));
+ TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path1)).last_point()) , Geom::Point(0,0));
+ TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path2)).last_point()) , Geom::Point(2,0));
+ TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path3)).last_point()) , Geom::Point(8,4));
+ TS_ASSERT_EQUALS(*(SPCurve(Geom::PathVector(1, path4)).last_point()) , Geom::Point(3,5));
Geom::PathVector pv;
+ TS_ASSERT(!SPCurve(pv).last_point());
pv.push_back(path1);
pv.push_back(path2);
pv.push_back(path3);
- TS_ASSERT_EQUALS(SPCurve(pv).last_point() , Geom::Point(8,4));
+ TS_ASSERT_EQUALS(*(SPCurve(pv).last_point()) , Geom::Point(8,4));
pv.push_back(path4);
- TS_ASSERT_EQUALS(SPCurve(pv).last_point() , Geom::Point(3,5));
+ TS_ASSERT_EQUALS(*(SPCurve(pv).last_point()) , Geom::Point(3,5));
}
void testSecondPoint()
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 9f6c34981e4aad37b21327949afb2bc926108940..8b1d977f565afb01e4258044c546f3407c85fbcc 100644 (file)
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
}
/**
- * Return first point of first subpath or (0,0). TODO: shouldn't this be (NR_HUGE, NR_HUGE) to be able to tell it apart from normal (0,0) ?
+ * Return first point of first subpath or nothing when the path is empty.
*/
-Geom::Point
+boost::optional<Geom::Point>
SPCurve::first_point() const
{
- if (is_empty())
- return Geom::Point(0, 0);
+ boost::optional<Geom::Point> retval;
+
+ if (!is_empty()) {
+ retval = _pathv.front().initialPoint();
+ }
- return _pathv.front().initialPoint();
+ return retval;
}
/**
}
/**
- * Return last point of last subpath or (0,0). TODO: shouldn't this be (NR_HUGE, NR_HUGE) to be able to tell it apart from normal (0,0) ?
+ * Return last point of last subpath or nothing when the curve is empty.
* If the last path is only a moveto, then return that point.
*/
boost::optional<Geom::Point>
{
boost::optional<Geom::Point> retval;
- if (is_empty())
- return Geom::Point(0, 0);
+ if (!is_empty()) {
+ retval = _pathv.back().finalPoint();
+ }
- return _pathv.back().finalPoint();
+ return retval;
}
/**
return this;
}
- if ( (fabs(this->last_point()[X] - c1->first_point()[X]) <= tolerance)
- && (fabs(this->last_point()[Y] - c1->first_point()[Y]) <= tolerance) )
+ if ( (fabs((*this->last_point())[X] - (*c1->first_point())[X]) <= tolerance)
+ && (fabs((*this->last_point())[Y] - (*c1->first_point())[Y]) <= tolerance) )
{
// c1's first subpath can be appended to this curve's last subpath
Geom::PathVector::const_iterator path_it = c1->_pathv.begin();
@@ -548,8 +552,8 @@ SPCurve::stretch_endpoints(Geom::Point const &new_p0, Geom::Point const &new_p1)
return;
}
- Geom::Point const offset0( new_p0 - first_point() );
- Geom::Point const offset1( new_p1 - last_point() );
+ Geom::Point const offset0( new_p0 - *first_point() );
+ Geom::Point const offset1( new_p1 - *last_point() );
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _pathv.front().toPwSb();
Geom::Piecewise<Geom::SBasis> arclength = Geom::arcLengthSb(pwd2);
diff --git a/src/display/curve.h b/src/display/curve.h
index 8bb3fb36012aed80f0ed327530aa5f6743454734..1b09c8c6e5e6f4d5146d1e0ec8ea5d796e22de0f 100644 (file)
--- a/src/display/curve.h
+++ b/src/display/curve.h
Geom::Path const * last_path() const;
Geom::Curve const * first_segment() const;
Geom::Path const * first_path() const;
- Geom::Point first_point() const;
- Geom::Point last_point() const;
+ boost::optional<Geom::Point> first_point() const;
+ boost::optional<Geom::Point> last_point() const;
boost::optional<Geom::Point> second_point() const;
boost::optional<Geom::Point> penultimate_point() const;
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index 97fcb7be6db9464444056189d662dd0f3a48f916..6f5d3e4e630a70bb9ce3bcdcf47f2d011d154f42 100644 (file)
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
g_return_if_fail( c->get_segment_count() > 0 );
if ( !c->is_closed() ) {
SPDrawAnchor *a;
- a = sp_draw_anchor_new(dc, c, TRUE, c->first_point());
+ a = sp_draw_anchor_new(dc, c, TRUE, *(c->first_point()));
dc->white_anchors = g_slist_prepend(dc->white_anchors, a);
- a = sp_draw_anchor_new(dc, c, FALSE, c->last_point());
+ a = sp_draw_anchor_new(dc, c, FALSE, *(c->last_point()));
dc->white_anchors = g_slist_prepend(dc->white_anchors, a);
}
}
index 3451a10b6629e0651db8556d0e323592c5ee2bde..dac34c5d485bad8057bae5966942e8e5f8b02463 100644 (file)
{
SPCurve *curve = SP_SHAPE(lpeitem)->curve;
- A = curve->first_point();
- B = curve->last_point();
+ A = *(curve->first_point());
+ B = *(curve->last_point());
origin.param_setValue(A);
index 027eda23f25d846cc60553431e9e5847fb54b15d..9ee53267c03542c046bce404456fd7c56701ae47 100644 (file)
void
LPEOffset::doOnApply(SPLPEItem *lpeitem)
{
- offset_pt.param_set_and_write_new_value(SP_SHAPE(lpeitem)->curve->first_point());
+ offset_pt.param_set_and_write_new_value(*(SP_SHAPE(lpeitem)->curve->first_point()));
}
static void append_half_circle(Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
index e169a3b8fbafdf32ad47647e2c30911bce4fe497..6b4a55504823de51cd9ae2db5ce38ae5b92ed6d1 100644 (file)
{
SPCurve *curve = SP_SHAPE(lpeitem)->curve;
- A = curve->first_point();
- B = curve->last_point();
+ A = *(curve->first_point());
+ B = *(curve->last_point());
dir = unit_vector(B - A);
offset_pt.param_set_and_write_new_value((A + B)/2 + dir.ccw() * 100);
index 44ba32e4dfb4451e62ffd074e8ab3f878ff4896a..dd6c5a90a705b4365f361d5d66343655d17e72ec 100644 (file)
double x1, y1;
double x2, y2;
- Geom::Point last = bi->curve->last_point();
+ Geom::Point last = *(bi->curve->last_point());
x0 = last[Geom::X];
y0 = last[Geom::Y];
x1 = xm + (1./3) * (x0 - xm);
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index 4a7032e707a0d37862bd79abdebd42d1ee76a75e..cd0f9be7f27972f4ed5be48156bac7bc37cf6139 100644 (file)
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
spdc_finish_endpoint(SPPencilContext *const pc)
{
if ( ( pc->red_curve->is_empty() )
- || ( pc->red_curve->first_point() == *(pc->red_curve->second_point()) ) )
+ || ( *(pc->red_curve->first_point()) == *(pc->red_curve->second_point()) ) )
{
pc->red_curve->reset();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL);
index 328f5a6962bf4b15d1f1f0d6bd883eee8e060b6f..0753e144138638af97d91c9b0095523e27919a44 100644 (file)
--- a/src/sp-conn-end-pair.cpp
+++ b/src/sp-conn-end-pair.cpp
else
{
if (h == 0) {
- endPts[h] = curve->first_point();
+ endPts[h] = *(curve->first_point());
}
else {
- endPts[h] = curve->last_point();
+ endPts[h] = *(curve->last_point());
}
}
}
diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp
index 947a88d714afc55e3c02e744d34472afe4c5890a..f529d6d6276c2bc326ebe086a42ce7a25446b40c 100644 (file)
--- a/src/sp-conn-end.cpp
+++ b/src/sp-conn-end.cpp
NR::Point other_endpt;
NR::Point last_seg_pt;
if (h2attItem[0] != NULL) {
- other_endpt = path->curve->last_point();
+ other_endpt = *(path->curve->last_point());
last_seg_pt = *(path->curve->second_point());
ind = 0;
}
else {
- other_endpt = path->curve->first_point();
+ other_endpt = *(path->curve->first_point());
last_seg_pt = *(path->curve->penultimate_point());
ind = 1;
}
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 8d7a4a2a19d57046b26037940931e13ef66a9cf4..f96d0a4f019e856cacc2601050b5ddc9bb43deb9 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) {
SPCurve *rc = SP_DRAW_CONTEXT(ec)->red_curve;
if (!rc->is_empty()) {
- NR::Point const zoom_to (rc->last_point());
+ Geom::Point const zoom_to (*rc->last_point());
dt->zoom_relative_keep_point(zoom_to, mul*zoom_inc);
break;
}
if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) {
SPCurve *rc = SP_DRAW_CONTEXT(ec)->red_curve;
if (!rc->is_empty()) {
- NR::Point const zoom_to (rc->last_point());
+ Geom::Point const zoom_to (*rc->last_point());
dt->zoom_relative_keep_point(zoom_to, 1 / (mul*zoom_inc));
break;
}