From 9dff787f0c9ff71746207bb2145c1c3a4d902a72 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 18 Aug 2012 18:14:21 +0200 Subject: Added "virtual pad" to SPLine. (bzr r11608.1.6) --- src/sp-line.cpp | 116 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 85 insertions(+), 31 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 06604a1d6..a431a0948 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -68,20 +68,31 @@ void SPLineClass::sp_line_class_init(SPLineClass *klass) shape_class->set_shape = SPLine::setShape; } +CLine::CLine(SPLine* line) : CShape(line) { + this->spline = line; +} + +CLine::~CLine() { +} + void SPLine::init(SPLine * line) { + line->cline = new CLine(line); + line->cshape = line->cline; + line->clpeitem = line->cline; + line->citem = line->cline; + line->cobject = line->cline; + line->x1.unset(); line->y1.unset(); line->x2.unset(); line->y2.unset(); } +void CLine::onBuild(SPDocument * document, Inkscape::XML::Node * repr) { + SPLine* object = this->spline; -void SPLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) -{ - if (((SPObjectClass *) SPLineClass::static_parent_class)->build) { - ((SPObjectClass *) SPLineClass::static_parent_class)->build(object, document, repr); - } + CShape::onBuild(document, repr); object->readAttr( "x1" ); object->readAttr( "y1" ); @@ -89,9 +100,15 @@ void SPLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node object->readAttr( "y2" ); } -void SPLine::set(SPObject *object, unsigned int key, const gchar *value) +// CPPIFY: remove +void SPLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - SPLine * line = SP_LINE(object); + ((SPLine*)object)->cline->onBuild(document, repr); +} + +void CLine::onSet(unsigned int key, const gchar* value) { + SPLine* object = this->spline; + SPLine * line = object; /* fixme: we should really collect updates */ @@ -113,15 +130,20 @@ void SPLine::set(SPObject *object, unsigned int key, const gchar *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) SPLineClass::static_parent_class)->set) { - ((SPObjectClass *) SPLineClass::static_parent_class)->set(object, key, value); - } + CShape::onSet(key, value); break; } } -void SPLine::update(SPObject *object, SPCtx *ctx, guint flags) +// CPPIFY: remove +void SPLine::set(SPObject *object, unsigned int key, const gchar *value) { + ((SPLine*)object)->cline->onSet(key, value); +} + +void CLine::onUpdate(SPCtx *ctx, guint flags) { + SPLine* object = this->spline; + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { SPLine *line = SP_LINE(object); @@ -139,15 +161,18 @@ void SPLine::update(SPObject *object, SPCtx *ctx, guint flags) ((SPShape *) object)->setShape(); } - if (((SPObjectClass *) SPLineClass::static_parent_class)->update) { - ((SPObjectClass *) SPLineClass::static_parent_class)->update(object, ctx, flags); - } + CShape::onUpdate(ctx, flags); } - -Inkscape::XML::Node * SPLine::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +// CPPIFY: remove +void SPLine::update(SPObject *object, SPCtx *ctx, guint flags) { - SPLine *line = SP_LINE(object); + ((SPLine*)object)->cline->onUpdate(ctx, flags); +} + +Inkscape::XML::Node* CLine::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPLine* object = this->spline; + SPLine *line = object; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:line"); @@ -162,21 +187,31 @@ Inkscape::XML::Node * SPLine::write(SPObject *object, Inkscape::XML::Document *x sp_repr_set_svg_double(repr, "x2", line->x2.computed); sp_repr_set_svg_double(repr, "y2", line->y2.computed); - if (((SPObjectClass *) (SPLineClass::static_parent_class))->write) { - ((SPObjectClass *) (SPLineClass::static_parent_class))->write(object, xml_doc, repr, flags); - } + CShape::onWrite(xml_doc, repr, flags); return repr; } -gchar * SPLine::getDescription(SPItem */*item*/) +// CPPIFY: remove +Inkscape::XML::Node * SPLine::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - return g_strdup(_("Line")); + return ((SPLine*)object)->cline->onWrite(xml_doc, repr, flags); } -void SPLine::convertToGuides(SPItem *item) +gchar* CLine::onDescription() { + return g_strdup(_("Line")); +} + +// CPPIFY: remove +gchar * SPLine::getDescription(SPItem *item) { - SPLine *line = SP_LINE(item); + return ((SPLine*)item)->cline->onDescription(); +} + +void CLine::onConvertToGuides() { + SPLine* item = this->spline; + SPLine *line = item; + Geom::Point points[2]; Geom::Affine const i2dt(item->i2dt_affine()); @@ -187,32 +222,45 @@ void SPLine::convertToGuides(SPItem *item) SPGuide::createSPGuide(item->document, points[0], points[1]); } -Geom::Affine SPLine::setTransform(SPItem *item, Geom::Affine const &xform) +// CPPIFY: remove +void SPLine::convertToGuides(SPItem *item) { - SPLine *line = SP_LINE(item); + ((SPLine*)item)->cline->onConvertToGuides(); +} + +Geom::Affine CLine::onSetTransform(Geom::Affine const &transform) { + SPLine* item = this->spline; + SPLine *line = item; + Geom::Point points[2]; points[0] = Geom::Point(line->x1.computed, line->y1.computed); points[1] = Geom::Point(line->x2.computed, line->y2.computed); - points[0] *= xform; - points[1] *= xform; + points[0] *= transform; + points[1] *= transform; line->x1.computed = points[0][Geom::X]; line->y1.computed = points[0][Geom::Y]; line->x2.computed = points[1][Geom::X]; line->y2.computed = points[1][Geom::Y]; - item->adjust_stroke(xform.descrim()); + item->adjust_stroke(transform.descrim()); SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); return Geom::identity(); } -void SPLine::setShape(SPShape *shape) +// CPPIFY: remove +Geom::Affine SPLine::setTransform(SPItem *item, Geom::Affine const &xform) { - SPLine *line = SP_LINE(shape); + return ((SPLine*)item)->cline->onSetTransform(xform); +} + +void CLine::onSetShape() { + SPLine* shape = this->spline; + SPLine *line = shape; SPCurve *c = new SPCurve(); @@ -227,6 +275,12 @@ void SPLine::setShape(SPShape *shape) c->unref(); } +// CPPIFY: remove +void SPLine::setShape(SPShape *shape) +{ + ((SPLine*)shape)->cline->onSetShape(); +} + /* Local Variables: mode:c++ -- cgit v1.2.3 From 260c7156ca920232cca2e829782373a805d59cae Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 29 Sep 2012 17:43:15 +0200 Subject: Removed old calls to set_shape and update_patheffect. (bzr r11608.1.45) --- src/sp-line.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index a431a0948..b39117d9e 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -65,7 +65,7 @@ void SPLineClass::sp_line_class_init(SPLineClass *klass) sp_object_class->update = SPLine::update; SPShapeClass *shape_class = (SPShapeClass *) klass; - shape_class->set_shape = SPLine::setShape; + //shape_class->set_shape = SPLine::setShape; } CLine::CLine(SPLine* line) : CShape(line) { -- cgit v1.2.3 From 99cb30e28d4ee193f39e23464abbd7630cac8a2d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 6 Oct 2012 23:56:27 +0200 Subject: Added virtual pad to SPFlowtext; removed old calls to virtual SPItem methods. (bzr r11608.1.46) --- src/sp-line.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index b39117d9e..4d017cf49 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -58,9 +58,9 @@ void SPLineClass::sp_line_class_init(SPLineClass *klass) sp_object_class->write = SPLine::write; SPItemClass *item_class = (SPItemClass *) klass; - item_class->description = SPLine::getDescription; - item_class->set_transform = SPLine::setTransform; - item_class->convert_to_guides = SPLine::convertToGuides; +// item_class->description = SPLine::getDescription; +// item_class->set_transform = SPLine::setTransform; +// item_class->convert_to_guides = SPLine::convertToGuides; sp_object_class->update = SPLine::update; -- cgit v1.2.3 From a0a8d020201e0e38a63d9aa3dce228d7d9e6fb35 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 14 Mar 2013 12:42:39 +0100 Subject: Various changes. (bzr r11608.1.48) --- src/sp-line.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 4d017cf49..b172d24a9 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -53,7 +53,7 @@ void SPLineClass::sp_line_class_init(SPLineClass *klass) SPLineClass::static_parent_class = (SPShapeClass *) g_type_class_ref(SP_TYPE_SHAPE); SPObjectClass *sp_object_class = (SPObjectClass *) klass; - sp_object_class->build = SPLine::build; + //sp_object_class->build = SPLine::build; sp_object_class->set = SPLine::set; sp_object_class->write = SPLine::write; -- cgit v1.2.3 From 957c3e4b7909d42c5a13f1b1dd583f877fc32259 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:46:57 +0100 Subject: Removed function pointers from SPObject and subclasses. Added some missing virtual pads for classes that were hidden by preprocessor macros. (bzr r11608.1.55) --- src/sp-line.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index b172d24a9..fa45ab571 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -54,15 +54,15 @@ void SPLineClass::sp_line_class_init(SPLineClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *) klass; //sp_object_class->build = SPLine::build; - sp_object_class->set = SPLine::set; - sp_object_class->write = SPLine::write; +// sp_object_class->set = SPLine::set; +// sp_object_class->write = SPLine::write; SPItemClass *item_class = (SPItemClass *) klass; // item_class->description = SPLine::getDescription; // item_class->set_transform = SPLine::setTransform; // item_class->convert_to_guides = SPLine::convertToGuides; - sp_object_class->update = SPLine::update; +// sp_object_class->update = SPLine::update; SPShapeClass *shape_class = (SPShapeClass *) klass; //shape_class->set_shape = SPLine::setShape; -- cgit v1.2.3 From 7df6616da5ea2debb86838366ddf746841549cdb Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:56:13 +0100 Subject: Renamed virtual function names. (bzr r11608.1.57) --- src/sp-line.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index bc198a6a5..71a9a78d6 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -56,10 +56,10 @@ sp_line_init(SPLine * line) line->y2.unset(); } -void CLine::onBuild(SPDocument * document, Inkscape::XML::Node * repr) { +void CLine::build(SPDocument * document, Inkscape::XML::Node * repr) { SPLine* object = this->spline; - CShape::onBuild(document, repr); + CShape::build(document, repr); object->readAttr( "x1" ); object->readAttr( "y1" ); @@ -67,7 +67,7 @@ void CLine::onBuild(SPDocument * document, Inkscape::XML::Node * repr) { object->readAttr( "y2" ); } -void CLine::onSet(unsigned int key, const gchar* value) { +void CLine::set(unsigned int key, const gchar* value) { SPLine* object = this->spline; SPLine * line = object; @@ -91,12 +91,12 @@ void CLine::onSet(unsigned int key, const gchar* value) { object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - CShape::onSet(key, value); + CShape::set(key, value); break; } } -void CLine::onUpdate(SPCtx *ctx, guint flags) { +void CLine::update(SPCtx *ctx, guint flags) { SPLine* object = this->spline; if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { @@ -116,10 +116,10 @@ void CLine::onUpdate(SPCtx *ctx, guint flags) { ((SPShape *) object)->setShape(); } - CShape::onUpdate(ctx, flags); + CShape::update(ctx, flags); } -Inkscape::XML::Node* CLine::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CLine::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPLine* object = this->spline; SPLine *line = object; @@ -136,16 +136,16 @@ Inkscape::XML::Node* CLine::onWrite(Inkscape::XML::Document *xml_doc, Inkscape:: sp_repr_set_svg_double(repr, "x2", line->x2.computed); sp_repr_set_svg_double(repr, "y2", line->y2.computed); - CShape::onWrite(xml_doc, repr, flags); + CShape::write(xml_doc, repr, flags); return repr; } -gchar* CLine::onDescription() { +gchar* CLine::description() { return g_strdup(_("Line")); } -void CLine::onConvertToGuides() { +void CLine::convert_to_guides() { SPLine* item = this->spline; SPLine *line = item; @@ -160,7 +160,7 @@ void CLine::onConvertToGuides() { } -Geom::Affine CLine::onSetTransform(Geom::Affine const &transform) { +Geom::Affine CLine::set_transform(Geom::Affine const &transform) { SPLine* item = this->spline; SPLine *line = item; @@ -184,7 +184,7 @@ Geom::Affine CLine::onSetTransform(Geom::Affine const &transform) { return Geom::identity(); } -void CLine::onSetShape() { +void CLine::set_shape() { SPLine* shape = this->spline; SPLine *line = shape; -- cgit v1.2.3 From a5d6e692d661f0bf7648e64e8fcb04588bb8f3ab Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 00:07:00 +0200 Subject: Prepared exchange of casting macros. (bzr r11608.1.63) --- src/sp-line.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 71a9a78d6..588e4f375 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -43,6 +43,7 @@ static void sp_line_init(SPLine * line) { line->cline = new CLine(line); + line->typeHierarchy.insert(typeid(SPLine)); delete line->cshape; line->cshape = line->cline; -- cgit v1.2.3 From 69f3b6f1abb2bb422935d43262e1e99aab359954 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 01:41:30 +0200 Subject: Added constructors to SP classes. (bzr r11608.1.67) --- src/sp-line.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 588e4f375..b6677baf3 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -25,7 +25,7 @@ #include "inkscape.h" -G_DEFINE_TYPE(SPLine, sp_line, SP_TYPE_SHAPE); +G_DEFINE_TYPE(SPLine, sp_line, G_TYPE_OBJECT); static void sp_line_class_init(SPLineClass *klass) @@ -39,9 +39,9 @@ CLine::CLine(SPLine* line) : CShape(line) { CLine::~CLine() { } -static void -sp_line_init(SPLine * line) -{ +SPLine::SPLine() : SPShape() { + SPLine* line = this; + line->cline = new CLine(line); line->typeHierarchy.insert(typeid(SPLine)); @@ -57,6 +57,12 @@ sp_line_init(SPLine * line) line->y2.unset(); } +static void +sp_line_init(SPLine * line) +{ + new (line) SPLine(); +} + void CLine::build(SPDocument * document, Inkscape::XML::Node * repr) { SPLine* object = this->spline; -- cgit v1.2.3 From d1af3566872dfff2aeec84859c87f1f8d13f79df Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 19:14:36 +0200 Subject: Registered classes with new factory. Hkern, Vkern and FeFuncX have to be rewritten, as they aren't real classes. (bzr r11608.1.69) --- src/sp-line.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index b6677baf3..d7ffa8307 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -24,6 +24,15 @@ #include "document.h" #include "inkscape.h" +#include "sp-factory.h" + +namespace { + SPObject* createLine() { + return new SPLine(); + } + + bool lineRegistered = SPFactory::instance().registerObject("svg:line", createLine); +} G_DEFINE_TYPE(SPLine, sp_line, G_TYPE_OBJECT); -- cgit v1.2.3 From 8443720ce6429b9beec839e60b8a808595f4ba72 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 23:01:45 +0200 Subject: Cleaned up a bit. Uses some C++11 features. (bzr r11608.1.72) --- src/sp-line.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index d7ffa8307..4a14b883c 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -34,13 +34,6 @@ namespace { bool lineRegistered = SPFactory::instance().registerObject("svg:line", createLine); } -G_DEFINE_TYPE(SPLine, sp_line, G_TYPE_OBJECT); - -static void -sp_line_class_init(SPLineClass *klass) -{ -} - CLine::CLine(SPLine* line) : CShape(line) { this->spline = line; } @@ -66,12 +59,6 @@ SPLine::SPLine() : SPShape() { line->y2.unset(); } -static void -sp_line_init(SPLine * line) -{ - new (line) SPLine(); -} - void CLine::build(SPDocument * document, Inkscape::XML::Node * repr) { SPLine* object = this->spline; -- cgit v1.2.3 From 748ffce08bb6250c87adabb64f45bff02509e9e7 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 00:27:58 +0200 Subject: Combined some classes. (bzr r11608.1.75) --- src/sp-line.cpp | 156 +++++++++++++++++++++++--------------------------------- 1 file changed, 65 insertions(+), 91 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 4a14b883c..d60969baa 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -34,170 +34,144 @@ namespace { bool lineRegistered = SPFactory::instance().registerObject("svg:line", createLine); } -CLine::CLine(SPLine* line) : CShape(line) { - this->spline = line; +SPLine::SPLine() : SPShape(), CShape(this) { + delete this->cshape; + this->cshape = this; + this->clpeitem = this; + this->citem = this; + this->cobject = this; + + this->x1.unset(); + this->y1.unset(); + this->x2.unset(); + this->y2.unset(); } -CLine::~CLine() { +SPLine::~SPLine() { } -SPLine::SPLine() : SPShape() { - SPLine* line = this; - - line->cline = new CLine(line); - line->typeHierarchy.insert(typeid(SPLine)); - - delete line->cshape; - line->cshape = line->cline; - line->clpeitem = line->cline; - line->citem = line->cline; - line->cobject = line->cline; - - line->x1.unset(); - line->y1.unset(); - line->x2.unset(); - line->y2.unset(); -} - -void CLine::build(SPDocument * document, Inkscape::XML::Node * repr) { - SPLine* object = this->spline; - +void SPLine::build(SPDocument * document, Inkscape::XML::Node * repr) { CShape::build(document, repr); - object->readAttr( "x1" ); - object->readAttr( "y1" ); - object->readAttr( "x2" ); - object->readAttr( "y2" ); + this->readAttr( "x1" ); + this->readAttr( "y1" ); + this->readAttr( "x2" ); + this->readAttr( "y2" ); } -void CLine::set(unsigned int key, const gchar* value) { - SPLine* object = this->spline; - SPLine * line = object; - +void SPLine::set(unsigned int key, const gchar* value) { /* fixme: we should really collect updates */ switch (key) { case SP_ATTR_X1: - line->x1.readOrUnset(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->x1.readOrUnset(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_Y1: - line->y1.readOrUnset(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->y1.readOrUnset(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_X2: - line->x2.readOrUnset(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->x2.readOrUnset(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_Y2: - line->y2.readOrUnset(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->y2.readOrUnset(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; + default: CShape::set(key, value); break; } } -void CLine::update(SPCtx *ctx, guint flags) { - SPLine* object = this->spline; - +void SPLine::update(SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - SPLine *line = SP_LINE(object); - - SPStyle const *style = object->style; + SPStyle const *style = this->style; SPItemCtx const *ictx = (SPItemCtx const *) ctx; double const w = ictx->viewport.width(); double const h = ictx->viewport.height(); double const em = style->font_size.computed; double const ex = em * 0.5; // fixme: get from pango or libnrtype. - line->x1.update(em, ex, w); - line->x2.update(em, ex, w); - line->y1.update(em, ex, h); - line->y2.update(em, ex, h); - ((SPShape *) object)->setShape(); + this->x1.update(em, ex, w); + this->x2.update(em, ex, w); + this->y1.update(em, ex, h); + this->y2.update(em, ex, h); + + this->setShape(); } CShape::update(ctx, flags); } -Inkscape::XML::Node* CLine::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPLine* object = this->spline; - SPLine *line = object; - +Inkscape::XML::Node* SPLine::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:line"); } - if (repr != object->getRepr()) { - repr->mergeFrom(object->getRepr(), "id"); + if (repr != this->getRepr()) { + repr->mergeFrom(this->getRepr(), "id"); } - sp_repr_set_svg_double(repr, "x1", line->x1.computed); - sp_repr_set_svg_double(repr, "y1", line->y1.computed); - sp_repr_set_svg_double(repr, "x2", line->x2.computed); - sp_repr_set_svg_double(repr, "y2", line->y2.computed); + sp_repr_set_svg_double(repr, "x1", this->x1.computed); + sp_repr_set_svg_double(repr, "y1", this->y1.computed); + sp_repr_set_svg_double(repr, "x2", this->x2.computed); + sp_repr_set_svg_double(repr, "y2", this->y2.computed); CShape::write(xml_doc, repr, flags); return repr; } -gchar* CLine::description() { +gchar* SPLine::description() { return g_strdup(_("Line")); } -void CLine::convert_to_guides() { - SPLine* item = this->spline; - SPLine *line = item; - +void SPLine::convert_to_guides() { Geom::Point points[2]; + Geom::Affine const i2dt(this->i2dt_affine()); - Geom::Affine const i2dt(item->i2dt_affine()); - - points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2dt; - points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2dt; + points[0] = Geom::Point(this->x1.computed, this->y1.computed)*i2dt; + points[1] = Geom::Point(this->x2.computed, this->y2.computed)*i2dt; - SPGuide::createSPGuide(item->document, points[0], points[1]); + SPGuide::createSPGuide(this->document, points[0], points[1]); } -Geom::Affine CLine::set_transform(Geom::Affine const &transform) { - SPLine* item = this->spline; - SPLine *line = item; - +Geom::Affine SPLine::set_transform(Geom::Affine const &transform) { Geom::Point points[2]; - points[0] = Geom::Point(line->x1.computed, line->y1.computed); - points[1] = Geom::Point(line->x2.computed, line->y2.computed); + points[0] = Geom::Point(this->x1.computed, this->y1.computed); + points[1] = Geom::Point(this->x2.computed, this->y2.computed); points[0] *= transform; points[1] *= transform; - line->x1.computed = points[0][Geom::X]; - line->y1.computed = points[0][Geom::Y]; - line->x2.computed = points[1][Geom::X]; - line->y2.computed = points[1][Geom::Y]; + this->x1.computed = points[0][Geom::X]; + this->y1.computed = points[0][Geom::Y]; + this->x2.computed = points[1][Geom::X]; + this->y2.computed = points[1][Geom::Y]; - item->adjust_stroke(transform.descrim()); + this->adjust_stroke(transform.descrim()); - SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); return Geom::identity(); } -void CLine::set_shape() { - SPLine* shape = this->spline; - SPLine *line = shape; - +void SPLine::set_shape() { SPCurve *c = new SPCurve(); - c->moveto(line->x1.computed, line->y1.computed); - c->lineto(line->x2.computed, line->y2.computed); + c->moveto(this->x1.computed, this->y1.computed); + c->lineto(this->x2.computed, this->y2.computed); - shape->setCurveInsync(c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update - shape->setCurveBeforeLPE(c); + this->setCurveInsync(c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update + this->setCurveBeforeLPE(c); // LPE's cannot be applied to lines. (the result can (generally) not be represented as SPLine) -- cgit v1.2.3 From cfe48de7f071e2e07a1f2f2ace3456f7b410e93b Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 15:37:33 +0200 Subject: Merged Shape and subclasses. Cleaned up a bit. (bzr r11608.1.76) --- src/sp-line.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index d60969baa..bb7abda8e 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -34,9 +34,7 @@ namespace { bool lineRegistered = SPFactory::instance().registerObject("svg:line", createLine); } -SPLine::SPLine() : SPShape(), CShape(this) { - delete this->cshape; - this->cshape = this; +SPLine::SPLine() : SPShape() { this->clpeitem = this; this->citem = this; this->cobject = this; @@ -51,7 +49,7 @@ SPLine::~SPLine() { } void SPLine::build(SPDocument * document, Inkscape::XML::Node * repr) { - CShape::build(document, repr); + SPShape::build(document, repr); this->readAttr( "x1" ); this->readAttr( "y1" ); @@ -84,7 +82,7 @@ void SPLine::set(unsigned int key, const gchar* value) { break; default: - CShape::set(key, value); + SPShape::set(key, value); break; } } @@ -103,10 +101,10 @@ void SPLine::update(SPCtx *ctx, guint flags) { this->y1.update(em, ex, h); this->y2.update(em, ex, h); - this->setShape(); + this->set_shape(); } - CShape::update(ctx, flags); + SPShape::update(ctx, flags); } Inkscape::XML::Node* SPLine::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { @@ -123,7 +121,7 @@ Inkscape::XML::Node* SPLine::write(Inkscape::XML::Document *xml_doc, Inkscape::X sp_repr_set_svg_double(repr, "x2", this->x2.computed); sp_repr_set_svg_double(repr, "y2", this->y2.computed); - CShape::write(xml_doc, repr, flags); + SPShape::write(xml_doc, repr, flags); return repr; } -- cgit v1.2.3 From 19d00efa85cfc42ccae9bd17ef575602f0d22c50 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 19:42:32 +0200 Subject: Merged more classes. (bzr r11608.1.78) --- src/sp-line.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index bb7abda8e..4c1fef70a 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -35,7 +35,6 @@ namespace { } SPLine::SPLine() : SPShape() { - this->clpeitem = this; this->citem = this; this->cobject = this; -- cgit v1.2.3 From 8073924aacdda310fb7492750f78d5389b3186af Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 22:45:01 +0200 Subject: Merged Item. (bzr r11608.1.81) --- src/sp-line.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 4c1fef70a..eee59930b 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -35,7 +35,6 @@ namespace { } SPLine::SPLine() : SPShape() { - this->citem = this; this->cobject = this; this->x1.unset(); -- cgit v1.2.3 From 27e2102f96a5554bcd5310ec11435d155773b279 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 7 Apr 2013 18:28:22 +0200 Subject: Merge Object and subclasses. Merging of SP- and C-classes complete. (bzr r11608.1.86) --- src/sp-line.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/sp-line.cpp') diff --git a/src/sp-line.cpp b/src/sp-line.cpp index eee59930b..3963007de 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -35,8 +35,6 @@ namespace { } SPLine::SPLine() : SPShape() { - this->cobject = this; - this->x1.unset(); this->y1.unset(); this->x2.unset(); -- cgit v1.2.3