From 0b7252e130dc81645a5148609ddb0fb4f6a3dd36 Mon Sep 17 00:00:00 2001 From: glenlow Date: Fri, 10 Apr 2009 03:27:17 +0000 Subject: [PATCH] connectable object model extra sparkling clean --- plugin/visio/VisioGraphic.cpp | 56 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/plugin/visio/VisioGraphic.cpp b/plugin/visio/VisioGraphic.cpp index d7252a5d8..d4af21712 100644 --- a/plugin/visio/VisioGraphic.cpp +++ b/plugin/visio/VisioGraphic.cpp @@ -65,6 +65,10 @@ namespace Visio gvprintf(job, "%d\n", _endArrow); gvputs(job, "\n"); } + + Geom::~Geom() + { + } Ellipse::Ellipse(pointf* points, bool filled): _filled(filled) @@ -95,11 +99,9 @@ namespace Visio return bounds; } - Connection Ellipse::GetConnection() const + const Connection* Ellipse::GetConnection() const { - Connection connection; - connection.connectable = false; - return connection; + return NULL; } Path::Path(pointf* points, int pointCount) @@ -151,14 +153,27 @@ namespace Visio { } - Connection Bezier::GetConnection() const + const Connection* Bezier::GetConnection() const + { + return this; + } + + pointf Bezier::GetFirst() const + { + return _points[0]; + } + + pointf Bezier::GetLast() const + { + return _points[1]; + } + + pointf Bezier::GetCenter() const { - Connection connection; - connection.connectable = true; - connection.first = _points[0]; - connection.last = _points[1]; if (_pointCount >= 4 && _pointCount % 2 == 0) { + pointf center; + /* the central control polygon for the bezier curve */ pointf p0 = _points[_pointCount / 2 - 2]; pointf p1 = _points[_pointCount / 2 - 1]; @@ -166,14 +181,13 @@ namespace Visio pointf p3 = _points[_pointCount / 2 + 1]; /* use de Casteljou's algorithm to get a midpoint */ - connection.center.x = 0.125 * p0.x + 0.375 * p1.x + 0.375 * p2.x + 0.125 * p3.x; - connection.center.y = 0.125 * p0.y + 0.375 * p1.y + 0.375 * p2.y + 0.125 * p3.y; + center.x = 0.125 * p0.x + 0.375 * p1.x + 0.375 * p2.x + 0.125 * p3.x; + center.y = 0.125 * p0.y + 0.375 * p1.y + 0.375 * p2.y + 0.125 * p3.y; + return center; } else /* just return the middle point */ - connection.center = _points[_pointCount / 2]; - - return connection; + return _points[_pointCount / 2]; } void Bezier::Print(GVJ_t* job, pointf first, pointf last, bool allowCurves) const @@ -269,11 +283,9 @@ namespace Visio { } - Connection Polygon::GetConnection() const + const Connection* Polygon::GetConnection() const { - Connection connection; - connection.connectable = false; - return connection; + return NULL; } void Polygon::Print(GVJ_t* job, pointf first, pointf last, bool allowCurves) const @@ -325,11 +337,9 @@ namespace Visio { } - Connection Polyline::GetConnection() const + const Connection* Polyline::GetConnection() const { - Connection connection; - connection.connectable = false; - return connection; + return NULL; } void Polyline::Print(GVJ_t* job, pointf first, pointf last, bool allowCurves) const @@ -521,7 +531,7 @@ namespace Visio return _geom->GetBounds(); } - Connection Graphic::GetConnection() const + const Connection* Graphic::GetConnection() const { return _geom->GetConnection(); } -- 2.40.0