summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-09-26 20:53:21 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-09-26 20:53:21 +0000
commit10388486debb4c9d6482a2c754edebc0ceff3760 (patch)
treeb0939271566fa26cbf3bc100ca3c7fea624f4354 /src
parentCompiling problem solved thaks to ~suv (diff)
parentcppcheck (diff)
downloadinkscape-10388486debb4c9d6482a2c754edebc0ceff3760.tar.gz
inkscape-10388486debb4c9d6482a2c754edebc0ceff3760.zip
update to trunk
(bzr r11950.1.150)
Diffstat (limited to 'src')
-rw-r--r--src/dropper-context.cpp17
-rw-r--r--src/dyna-draw-context.cpp15
-rw-r--r--src/file.cpp8
-rw-r--r--src/libuemf/uemf_print.c32
-rw-r--r--src/lpe-tool-context.cpp4
-rw-r--r--src/object-snapper.cpp6
-rw-r--r--src/selection-chemistry.cpp10
-rw-r--r--src/sp-ellipse.cpp90
-rw-r--r--src/sp-flowtext.cpp2
-rw-r--r--src/sp-item-group.cpp4
-rw-r--r--src/sp-shape.cpp47
-rw-r--r--src/sp-spiral.cpp87
-rw-r--r--src/sp-spiral.h13
-rw-r--r--src/sp-use.cpp245
-rw-r--r--src/sp-use.h31
-rw-r--r--src/spray-context.cpp14
-rw-r--r--src/tweak-context.cpp14
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp4
-rw-r--r--src/ui/tool/path-manipulator.cpp2
19 files changed, 302 insertions, 343 deletions
diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp
index d513dd587..dcb1ab66c 100644
--- a/src/dropper-context.cpp
+++ b/src/dropper-context.cpp
@@ -19,6 +19,7 @@
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <2geom/transforms.h>
+#include <2geom/circle.h>
#include "macros.h"
#include "display/canvas-bpath.h"
@@ -92,16 +93,14 @@ SPDropperContext::~SPDropperContext() {
void SPDropperContext::setup() {
SPEventContext::setup();
- /* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
- SPCurve *c = new SPCurve();
- const double C1 = 0.552;
- c->moveto(-1,0);
- c->curveto(-1, C1, -C1, 1, 0, 1 );
- c->curveto(C1, 1, 1, C1, 1, 0 );
- c->curveto(1, -C1, C1, -1, 0, -1 );
- c->curveto(-C1, -1, -1, -C1, -1, 0 );
- c->closepath();
+ /* TODO: have a look at SPDynaDrawContext::setup where the same is done.. generalize? */
+ Geom::PathVector path;
+ Geom::Circle(0, 0, 1).getPath(path);
+
+ SPCurve *c = new SPCurve(path);
+
this->area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c);
+
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->area), 0x00000000,(SPWindRule)0);
diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp
index 3e35c0ac1..01f71f76a 100644
--- a/src/dyna-draw-context.cpp
+++ b/src/dyna-draw-context.cpp
@@ -38,6 +38,7 @@
#include <2geom/math-utils.h>
#include <2geom/pathvector.h>
#include <2geom/bezier-utils.h>
+#include <2geom/circle.h>
#include "display/curve.h"
#include <glib.h>
#include "macros.h"
@@ -151,17 +152,11 @@ void SPDynaDrawContext::setup() {
g_signal_connect(G_OBJECT(this->currentshape), "event", G_CALLBACK(sp_desktop_root_handler), this->desktop);
{
- /* TODO: this can be done either with an arcto, and should maybe also be put in a general file (other tools use this as well) */
- SPCurve *c = new SPCurve();
+ /* TODO: have a look at SPDropperContext::setup where the same is done.. generalize? */
+ Geom::PathVector path;
+ Geom::Circle(0, 0, 1).getPath(path);
- const double C1 = 0.552;
-
- c->moveto(-1,0);
- c->curveto(-1, C1, -C1, 1, 0, 1 );
- c->curveto(C1, 1, 1, C1, 1, 0 );
- c->curveto(1, -C1, C1, -1, 0, -1 );
- c->curveto(-C1, -1, -1, -C1, -1, 0 );
- c->closepath();
+ SPCurve *c = new SPCurve(path);
this->hatch_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c);
diff --git a/src/file.cpp b/src/file.cpp
index b19fe21ff..e0675e8cf 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -1143,7 +1143,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
Inkscape::Extension::Extension *key)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
+ bool cancelled = false;
+
//DEBUG_MESSAGE( fileImport, "file_import( in_doc:%p uri:[%s], key:%p", in_doc, uri, key );
SPDocument *doc;
try {
@@ -1152,6 +1153,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
doc = NULL;
} catch (Inkscape::Extension::Input::open_failed &e) {
doc = NULL;
+ } catch (Inkscape::Extension::Input::open_cancelled &e) {
+ doc = NULL;
+ cancelled = true;
}
if (doc != NULL) {
@@ -1248,7 +1252,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
DocumentUndo::done(in_doc, SP_VERB_FILE_IMPORT,
_("Import"));
return new_obj;
- } else {
+ } else if (!cancelled) {
gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), uri.c_str());
sp_ui_error_dialog(text);
g_free(text);
diff --git a/src/libuemf/uemf_print.c b/src/libuemf/uemf_print.c
index 4ea9620cf..b4e1753c6 100644
--- a/src/libuemf/uemf_print.c
+++ b/src/libuemf/uemf_print.c
@@ -407,7 +407,7 @@ void extlogpen_print(
printf("elpStyleEntry:");
elpStyleEntry = (uint32_t *) elp->elpStyleEntry;
for(i=0;i<elp->elpNumEntries;i++){
- printf("%d:%u ",i,elpStyleEntry[i]);
+ printf("%u:%u ",i,elpStyleEntry[i]);
}
}
}
@@ -484,7 +484,7 @@ void rgndata_print(
if(rd->rdh.nCount){
rects = (PU_RECTL) &(rd->Buffer);
for(i=0;i<rd->rdh.nCount;i++){
- printf("%d:",i); rectl_print(rects[i]);
+ printf("%u:",i); rectl_print(rects[i]);
}
}
}
@@ -616,7 +616,7 @@ void core1_print(const char *name, const char *contents){
printf(" cptl: %d\n",pEmr->cptl );
printf(" Points: ");
for(i=0;i<pEmr->cptl; i++){
- printf("[%d]:",i); pointl_print(pEmr->aptl[i]);
+ printf("[%u]:",i); pointl_print(pEmr->aptl[i]);
}
printf("\n");
}
@@ -631,13 +631,13 @@ void core2_print(const char *name, const char *contents){
printf(" cptl: %d\n",pEmr->cptl );
printf(" Counts: ");
for(i=0;i<pEmr->nPolys; i++){
- printf(" [%d]:%d ",i,pEmr->aPolyCounts[i] );
+ printf(" [%u]:%d ",i,pEmr->aPolyCounts[i] );
}
printf("\n");
PU_POINTL paptl = (PU_POINTL)((char *)pEmr->aPolyCounts + sizeof(uint32_t)* pEmr->nPolys);
printf(" Points: ");
for(i=0;i<pEmr->cptl; i++){
- printf(" [%d]:",i); pointl_print(paptl[i]);
+ printf(" [%u]:",i); pointl_print(paptl[i]);
}
printf("\n");
}
@@ -675,7 +675,7 @@ void core6_print(const char *name, const char *contents){
printf(" Points: ");
PU_POINT16 papts = (PU_POINT16)(&(pEmr->apts));
for(i=0; i<pEmr->cpts; i++){
- printf(" [%d]:",i); point16_print(papts[i]);
+ printf(" [%u]:",i); point16_print(papts[i]);
}
printf("\n");
}
@@ -729,7 +729,7 @@ void core10_print(const char *name, const char *contents){
printf(" cpts: %d\n",pEmr->cpts );
printf(" Counts: ");
for(i=0;i<pEmr->nPolys; i++){
- printf(" [%d]:%d ",i,pEmr->aPolyCounts[i] );
+ printf(" [%u]:%d ",i,pEmr->aPolyCounts[i] );
}
printf("\n");
printf(" Points: ");
@@ -753,7 +753,7 @@ void core11_print(const char *name, const char *contents){
i=1;
char *prd = (char *) &(pEmr->RgnData);
while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record
- printf(" RegionData:%d",i);
+ printf(" RegionData:%u",i);
rgndata_print((PU_RGNDATA) (prd + roff));
roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16);
printf("\n");
@@ -1362,7 +1362,7 @@ void U_EMRSETPALETTEENTRIES_print(const char *contents){
printf(" PLTEntries:");
PU_LOGPLTNTRY aPalEntries = (PU_LOGPLTNTRY) &(pEmr->aPalEntries);
for(i=0; i<pEmr->cEntries; i++){
- printf("%d:",i); logpltntry_print(aPalEntries[i]);
+ printf("%u:",i); logpltntry_print(aPalEntries[i]);
}
printf("\n");
}
@@ -1428,13 +1428,13 @@ void U_EMRPOLYDRAW_print(const char *contents){
printf(" cptl: %d\n",pEmr->cptl );
printf(" Points: ");
for(i=0;i<pEmr->cptl; i++){
- printf(" [%d]:",i);
+ printf(" [%u]:",i);
pointl_print(pEmr->aptl[i]);
}
printf("\n");
printf(" Types: ");
for(i=0;i<pEmr->cptl; i++){
- printf(" [%d]:%u ",i,pEmr->abTypes[i]);
+ printf(" [%u]:%u ",i,pEmr->abTypes[i]);
}
printf("\n");
}
@@ -1619,7 +1619,7 @@ void U_EMRFILLRGN_print(const char *contents){
i=1;
char *prd = (char *) &(pEmr->RgnData);
while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record
- printf(" RegionData[%d]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n");
+ printf(" RegionData[%u]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n");
roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16);
}
}
@@ -1641,7 +1641,7 @@ void U_EMRFRAMERGN_print(const char *contents){
i=1;
char *prd = (char *) &(pEmr->RgnData);
while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record
- printf(" RegionData[%d]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n");
+ printf(" RegionData[%u]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n");
roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16);
}
}
@@ -1973,13 +1973,13 @@ void U_EMRPOLYDRAW16_print(const char *contents){
printf(" cpts: %d\n",pEmr->cpts );
printf(" Points: ");
for(i=0;i<pEmr->cpts; i++){
- printf(" [%d]:",i);
+ printf(" [%u]:",i);
point16_print(pEmr->apts[i]);
}
printf("\n");
printf(" Types: ");
for(i=0;i<pEmr->cpts; i++){
- printf(" [%d]:%u ",i,pEmr->abTypes[i]);
+ printf(" [%u]:%u ",i,pEmr->abTypes[i]);
}
printf("\n");
}
@@ -2218,7 +2218,7 @@ void U_EMRCREATECOLORSPACEW_print(const char *contents){
printf(" Data: ");
if(pEmr->dwFlags & 1){
for(i=0; i<pEmr->cbData; i++){
- printf("[%d]:%2.2X ",i,pEmr->Data[i]);
+ printf("[%u]:%2.2X ",i,pEmr->Data[i]);
}
}
printf("\n");
diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp
index 14a536b7d..bcf58aaf3 100644
--- a/src/lpe-tool-context.cpp
+++ b/src/lpe-tool-context.cpp
@@ -410,7 +410,7 @@ lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *select
for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
if (SP_IS_PATH(i->data)) {
path = SP_PATH(i->data);
- curve = SP_SHAPE(path)->getCurve();
+ curve = path->getCurve();
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = paths_to_pw(curve->get_pathvector());
canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), "");
if (!show)
@@ -453,7 +453,7 @@ lpetool_update_measuring_items(SPLPEToolContext *lc)
++i )
{
SPPath *path = i->first;
- SPCurve *curve = SP_SHAPE(path)->getCurve();
+ SPCurve *curve = path->getCurve();
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector());
Inkscape::Util::Unit unit;
if (prefs->getString("/tools/lpetool/unit").compare("")) {
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index c5a3e1e88..3f3f0c1bf 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -194,7 +194,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t,
//Geom::Affine i2doc(Geom::identity());
SPItem *root_item = (*i).item;
if (SP_IS_USE((*i).item)) {
- root_item = sp_use_root(SP_USE((*i).item));
+ root_item = SP_USE((*i).item)->root();
}
g_return_if_fail(root_item);
@@ -382,8 +382,8 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/,
SPItem *root_item = NULL;
/* We might have a clone at hand, so make sure we get the root item */
if (SP_IS_USE((*i).item)) {
- i2doc = sp_use_get_root_transform(SP_USE((*i).item));
- root_item = sp_use_root(SP_USE((*i).item));
+ i2doc = SP_USE((*i).item)->get_root_transform();
+ root_item = SP_USE((*i).item)->root();
g_return_if_fail(root_item);
} else {
i2doc = (*i).item->i2doc_affine();
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 8a414eb4b..c22ed777b 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -499,7 +499,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
const gchar *id = old_ids[i];
SPObject *old_clone = doc->getObjectById(id);
if (SP_IS_USE(old_clone)) {
- SPItem *orig = sp_use_get_original(SP_USE(old_clone));
+ SPItem *orig = SP_USE(old_clone)->get_original();
if (!orig) // orphaned
continue;
for (unsigned int j = 0; j < old_ids.size(); j++) {
@@ -1382,7 +1382,7 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection)
SPItem *item_use_first = item;
while (is_use && item_use && !contains_original)
{
- item_use = sp_use_get_original(SP_USE(item_use));
+ item_use = SP_USE(item_use)->get_original();
contains_original |= selection->includes(item_use);
if (item_use == item_use_first)
break;
@@ -1527,7 +1527,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
// we need to cancel out the move compensation, too
// find out the clone move, same as in sp_use_move_compensate
- Geom::Affine parent = sp_use_get_parent_transform(SP_USE(item));
+ Geom::Affine parent = SP_USE(item)->get_parent_transform();
Geom::Affine clone_move = parent.inverse() * t * parent;
if (prefs_parallel) {
@@ -2623,7 +2623,7 @@ sp_selection_unlink(SPDesktop *desktop)
SPItem *unlink;
if (SP_IS_USE(item)) {
- unlink = sp_use_unlink(SP_USE(item));
+ unlink = SP_USE(item)->unlink();
// Unable to unlink use (external or invalid href?)
if (!unlink) {
new_select = g_slist_prepend(new_select, item);
@@ -2671,7 +2671,7 @@ sp_select_clone_original(SPDesktop *desktop)
SPItem *original = NULL;
if (SP_IS_USE(item)) {
- original = sp_use_get_original(SP_USE(item));
+ original = SP_USE(item)->get_original();
} else if (SP_IS_OFFSET(item) && SP_OFFSET(item)->sourceHref) {
original = sp_offset_get_source(SP_OFFSET(item));
} else if (SP_IS_TEXT_TEXTPATH(item)) {
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index 2d73ff35f..fc78b9777 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -26,6 +26,7 @@
#include <glibmm/i18n.h>
#include <2geom/transforms.h>
#include <2geom/pathvector.h>
+#include <2geom/svg-path.h>
#include "document.h"
#include "sp-ellipse.h"
#include "preferences.h"
@@ -141,6 +142,8 @@ void SPGenericEllipse::update_patheffect(bool write) {
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
+#include <2geom/ellipse.h>
+
/* fixme: Think (Lauris) */
/* Can't we use arcto in this method? */
void SPGenericEllipse::set_shape() {
@@ -158,12 +161,6 @@ void SPGenericEllipse::set_shape() {
return;
}
- double rx;
- double ry;
- double s;
- double len;
- gint slice = FALSE;
-
if ((this->rx.computed < 1e-18) || (this->ry.computed < 1e-18)) {
return;
}
@@ -174,58 +171,65 @@ void SPGenericEllipse::set_shape() {
sp_genericellipse_normalize(this);
- rx = this->rx.computed;
- ry = this->ry.computed;
-
// figure out if we have a slice, guarding against rounding errors
- len = fmod(this->end - this->start, SP_2PI);
+ double len = fmod(this->end - this->start, SP_2PI);
if (len < 0.0) {
len += SP_2PI;
}
+ bool slice = false;
+
if (fabs(len) < 1e-8 || fabs(len - SP_2PI) < 1e-8) {
- slice = FALSE;
+ slice = false;
this->end = this->start + SP_2PI;
} else {
- slice = TRUE;
+ slice = true;
}
- SPCurve * curve = new SPCurve();
- curve->moveto(cos(this->start), sin(this->start));
+ SPCurve *curve = NULL;
+
+ // For simplicity, we use a circle with center (0, 0) and radius 1 for our calculations.
+
+ if (slice) {
+ Geom::Point startPoint(cos(start), sin(start));
+ Geom::Point endPoint(cos(end), sin(end));
+ Geom::Point middlePoint = make_angle_bisector_ray(Geom::Ray(Geom::Point(), start), Geom::Ray(Geom::Point(), end)).versor();
- for (s = this->start; s < this->end; s += M_PI_2) {
- double e = s + M_PI_2;
+ Geom::Ellipse ellipse(0, 0, 1, 1, 0);
+ Geom::EllipticalArc *arc = ellipse.arc(startPoint, middlePoint, endPoint);
- if (e > this->end) {
- e = this->end;
+ Geom::Path path(startPoint);
+ path.append(*arc);
+
+ delete arc;
+
+ Geom::PathBuilder pb;
+ pb.append(path);
+
+ if (this->closed) {
+ // "pizza slice"
+ pb.lineTo(Geom::Point(0, 0));
+ pb.closePath();
+ } else {
+ // arc only
+ pb.finish();
}
- len = 4*tan((e - s)/4)/3;
- double x0 = cos(s);
- double y0 = sin(s);
- double x1 = x0 + len * cos(s + M_PI_2);
- double y1 = y0 + len * sin(s + M_PI_2);
- double x3 = cos(e);
- double y3 = sin(e);
- double x2 = x3 + len * cos(e - M_PI_2);
- double y2 = y3 + len * sin(e - M_PI_2);
-#ifdef ELLIPSE_VERBOSE
- g_print("step %d s %f e %f coords %f %f %f %f %f %f\n",
- i, s, e, x1, y1, x2, y2, x3, y3);
-#endif
- curve->curveto(x1,y1, x2,y2, x3,y3);
- }
+ curve = new SPCurve(pb.peek());
+ } else {
+ // Full ellipse
+ Geom::Circle circle(0, 0, 1);
+ Geom::PathVector path;
- if (slice && this->closed) { // TODO: is this check for "ellipse->closed" necessary?
- curve->lineto(0., 0.);
- }
+ circle.getPath(path);
- if (this->closed) {
+ curve = new SPCurve(path);
curve->closepath();
}
- Geom::Affine aff = Geom::Scale(rx, ry) * Geom::Translate(this->cx.computed, this->cy.computed);
+ // Stretching / moving the calculated shape to fit the actual dimensions.
+ Geom::Affine aff = Geom::Scale(rx.computed, ry.computed) * Geom::Translate(cx.computed, cy.computed);
curve->transform(aff);
/* Reset the shape's curve to the "original_curve"
@@ -271,8 +275,6 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p,
double cx = this->cx.computed;
double cy = this->cy.computed;
- Geom::Point pt;
-
// Snap to the 4 quadrant points of the this, but only if the arc
// spans far enough to include them
if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)) {
@@ -280,7 +282,7 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p,
for (angle = 0; angle < SP_2PI; angle += M_PI_2) {
if (angle >= this->start && angle <= this->end) {
- pt = Geom::Point(cx + cos(angle)*rx, cy + sin(angle)*ry) * i2dt;
+ Geom::Point pt = Geom::Point(cx + cos(angle)*rx, cy + sin(angle)*ry) * i2dt;
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ELLIPSE_QUADRANT_POINT, Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT));
}
}
@@ -291,7 +293,7 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p,
bool c2 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT);
if (c1 || c2) {
- pt = Geom::Point(cx, cy) * i2dt;
+ Geom::Point pt = Geom::Point(cx, cy) * i2dt;
if (c1) {
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
@@ -306,13 +308,13 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p,
if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice) {
// Add the start point, if it's not coincident with a quadrant point
if (fmod(this->start, M_PI_2) != 0.0 ) {
- pt = Geom::Point(cx + cos(this->start)*rx, cy + sin(this->start)*ry) * i2dt;
+ Geom::Point pt = Geom::Point(cx + cos(this->start)*rx, cy + sin(this->start)*ry) * i2dt;
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
}
// Add the end point, if it's not coincident with a quadrant point
if (fmod(this->end, M_PI_2) != 0.0 ) {
- pt = Geom::Point(cx + cos(this->end)*rx, cy + sin(this->end)*ry) * i2dt;
+ Geom::Point pt = Geom::Point(cx + cos(this->end)*rx, cy + sin(this->end)*ry) * i2dt;
p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
}
}
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index 5e13218f5..88564c0ac 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -582,7 +582,7 @@ SPItem *SPFlowtext::get_frame(SPItem *after)
}
if ( frame && SP_IS_USE(frame) ) {
- frame = sp_use_get_original(SP_USE(frame));
+ frame = SP_USE(frame)->get_original();
}
}
return frame;
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index bdcfe46d0..a99a3e988 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -472,8 +472,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
// Merging transform
Geom::Affine ctrans;
Geom::Affine const g(gitem->transform);
- if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) &&
- sp_use_get_original( SP_USE(citem) )->parent == SP_OBJECT(group)) {
+ if (SP_IS_USE(citem) && SP_USE(citem)->get_original() &&
+ SP_USE(citem)->get_original()->parent == SP_OBJECT(group)) {
// make sure a clone's effective transform is the same as was under group
ctrans = g.inverse() * citem->transform * g;
} else {
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 7efe28dd8..913e208aa 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -93,16 +93,13 @@ void SPShape::build(SPDocument *document, Inkscape::XML::Node *repr) {
* \see SPObject::release()
*/
void SPShape::release() {
- SPItemView *v;
- int i;
-
- for (i = 0; i < SP_MARKER_LOC_QTY; i++) {
+ for (int i = 0; i < SP_MARKER_LOC_QTY; i++) {
if (this->_marker[i]) {
-
- for (v = this->display; v != NULL; v = v->next) {
+
+ for (SPItemView *v = this->display; v != NULL; v = v->next) {
sp_marker_hide ((SPMarker *) this->_marker[i], v->arenaitem->key() + i);
}
-
+
this->_release_connect[i].disconnect();
this->_modified_connect[i].disconnect();
this->_marker[i] = sp_object_hunref (this->_marker[i], this);
@@ -143,16 +140,14 @@ void SPShape::update(SPCtx* ctx, guint flags) {
}
if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- SPStyle *style = this->style;
-
- if (style->stroke_width.unit == SP_CSS_UNIT_PERCENT) {
+ if (this->style->stroke_width.unit == SP_CSS_UNIT_PERCENT) {
SPItemCtx *ictx = (SPItemCtx *) ctx;
double const aw = 1.0 / ictx->i2vp.descrim();
- style->stroke_width.computed = style->stroke_width.value * aw;
+ this->style->stroke_width.computed = this->style->stroke_width.value * aw;
for (SPItemView *v = ((SPItem *) (this))->display; v != NULL; v = v->next) {
Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem);
- sh->setStyle(style);
+ sh->setStyle(this->style);
}
}
}
@@ -219,8 +214,7 @@ Geom::Affine sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve c
double const angle1 = Geom::atan2(tang1);
double const angle2 = Geom::atan2(tang2);
- double ret_angle;
- ret_angle = .5 * (angle1 + angle2);
+ double ret_angle = .5 * (angle1 + angle2);
if ( fabs( angle2 - angle1 ) > M_PI ) {
/* ret_angle is in the middle of the larger of the two sectors between angle1 and
@@ -281,8 +275,6 @@ Geom::Affine sp_shape_marker_get_transform_at_end(Geom::Curve const & c)
static void
sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai)
{
- SPStyle *style = ((SPObject *) shape)->style;
-
// position arguments to sp_marker_show_instance, basically counts the amount of markers.
int counter[4] = {0};
@@ -300,7 +292,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai)
if ( shape->_marker[i] ) {
sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai,
ai->key() + i, counter[i], m,
- style->stroke_width.computed);
+ shape->style->stroke_width.computed);
counter[i]++;
}
}
@@ -318,7 +310,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai)
if ( shape->_marker[i] ) {
sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai,
ai->key() + i, counter[i], m,
- style->stroke_width.computed);
+ shape->style->stroke_width.computed);
counter[i]++;
}
}
@@ -338,7 +330,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai)
if (shape->_marker[i]) {
sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai,
ai->key() + i, counter[i], m,
- style->stroke_width.computed);
+ shape->style->stroke_width.computed);
counter[i]++;
}
}
@@ -355,7 +347,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai)
if (shape->_marker[i]) {
sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai,
ai->key() + i, counter[i], m,
- style->stroke_width.computed);
+ shape->style->stroke_width.computed);
counter[i]++;
}
}
@@ -379,7 +371,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai)
if (shape->_marker[i]) {
sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai,
ai->key() + i, counter[i], m,
- style->stroke_width.computed);
+ shape->style->stroke_width.computed);
counter[i]++;
}
}
@@ -412,9 +404,8 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
if (bboxtype == SPItem::VISUAL_BBOX) {
// convert the stroke to a path and calculate that path's geometric bbox
- SPStyle* style = this->style;
- if (!style->stroke.isNone()) {
+ if (!this->style->stroke.isNone()) {
Geom::PathVector *pathv = item_outline(this, true); // calculate bbox_only
if (pathv) {
@@ -442,7 +433,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(this->style->stroke_width.computed) * tr;
}
// total marker transform
@@ -480,7 +471,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(this->style->stroke_width.computed) * tr;
}
tr = marker_item->transform * marker->c2p * tr * transform;
@@ -510,7 +501,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(this->style->stroke_width.computed) * tr;
}
tr = marker_item->transform * marker->c2p * tr * transform;
@@ -533,7 +524,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(this->style->stroke_width.computed) * tr;
}
tr = marker_item->transform * marker->c2p * tr * transform;
@@ -568,7 +559,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(this->style->stroke_width.computed) * tr;
}
// total marker transform
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index e911e722c..5d80e43fe 100644
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
@@ -38,14 +38,16 @@ namespace {
bool spiralRegistered = SPFactory::instance().registerObject("spiral", createSpiral);
}
-SPSpiral::SPSpiral() : SPShape() {
- this->cx = 0.0;
- this->cy = 0.0;
- this->exp = 1.0;
- this->revo = 3.0;
- this->rad = 1.0;
- this->arg = 0.0;
- this->t0 = 0.0;
+SPSpiral::SPSpiral()
+ : SPShape()
+ , cx(0)
+ , cy(0)
+ , exp(1)
+ , revo(3)
+ , rad(1)
+ , arg(0)
+ , t0(0)
+{
}
SPSpiral::~SPSpiral() {
@@ -85,11 +87,12 @@ Inkscape::XML::Node* SPSpiral::write(Inkscape::XML::Document *xml_doc, Inkscape:
// make sure the curve is rebuilt with all up-to-date parameters
this->set_shape();
- //Nulls might be possible if this called iteratively
+ // Nulls might be possible if this called iteratively
if (!this->_curve) {
//g_warning("sp_spiral_write(): No path to copy\n");
return NULL;
}
+
char *d = sp_svg_write_path(this->_curve->get_pathvector());
repr->setAttribute("d", d);
g_free(d);
@@ -198,24 +201,21 @@ void SPSpiral::set(unsigned int key, gchar const* value) {
}
void SPSpiral::update(SPCtx *ctx, guint flags) {
- SPSpiral* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- reinterpret_cast<SPShape *>(object)->set_shape();
+ this->set_shape();
}
SPShape::update(ctx, flags);
}
void SPSpiral::update_patheffect(bool write) {
- SPSpiral* shape = this;
-
this->set_shape();
if (write) {
- Inkscape::XML::Node *repr = shape->getRepr();
- if ( shape->_curve != NULL ) {
- gchar *str = sp_svg_write_path(shape->_curve->get_pathvector());
+ Inkscape::XML::Node *repr = this->getRepr();
+
+ if ( this->_curve != NULL ) {
+ gchar *str = sp_svg_write_path(this->_curve->get_pathvector());
repr->setAttribute("d", str);
g_free(str);
} else {
@@ -223,7 +223,7 @@ void SPSpiral::update_patheffect(bool write) {
}
}
- shape->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
const char* SPSpiral::displayName() {
@@ -233,7 +233,7 @@ const char* SPSpiral::displayName() {
gchar* SPSpiral::description() {
// TRANSLATORS: since turn count isn't an integer, please adjust the
// string as needed to deal with an localized plural forms.
- return g_strdup_printf (_("with %3f turns"), SP_SPIRAL(this)->revo);
+ return g_strdup_printf (_("with %3f turns"), this->revo);
}
/**
@@ -323,18 +323,15 @@ void SPSpiral::fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom::
}
void SPSpiral::set_shape() {
- SPSpiral *spiral = this;
- SPSpiral* shape = spiral;
-
if (hasBrokenPathEffect()) {
g_warning ("The spiral shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as spiral will remove the bad LPE");
- if (shape->getRepr()->attribute("d")) {
+ if (this->getRepr()->attribute("d")) {
// unconditionally read the curve from d, if any, to preserve appearance
- Geom::PathVector pv = sp_svg_read_pathv(shape->getRepr()->attribute("d"));
+ Geom::PathVector pv = sp_svg_read_pathv(this->getRepr()->attribute("d"));
SPCurve *cold = new SPCurve(pv);
- shape->setCurveInsync( cold, TRUE);
- shape->setCurveBeforeLPE( cold );
+ this->setCurveInsync( cold, TRUE);
+ this->setCurveBeforeLPE( cold );
cold->unref();
}
@@ -342,40 +339,40 @@ void SPSpiral::set_shape() {
}
Geom::Point darray[SAMPLE_SIZE + 1];
- double t;
- spiral->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
SPCurve *c = new SPCurve ();
#ifdef SPIRAL_VERBOSE
g_print ("cx=%g, cy=%g, exp=%g, revo=%g, rad=%g, arg=%g, t0=%g\n",
- spiral->cx,
- spiral->cy,
- spiral->exp,
- spiral->revo,
- spiral->rad,
- spiral->arg,
- spiral->t0);
+ this->cx,
+ this->cy,
+ this->exp,
+ this->revo,
+ this->rad,
+ this->arg,
+ this->t0);
#endif
/* Initial moveto. */
- c->moveto(spiral->getXY(spiral->t0));
+ c->moveto(this->getXY(this->t0));
- double const tstep = SAMPLE_STEP / spiral->revo;
+ double const tstep = SAMPLE_STEP / this->revo;
double const dstep = tstep / (SAMPLE_SIZE - 1);
- Geom::Point hat1 = spiral->getTangent(spiral->t0);
+ Geom::Point hat1 = this->getTangent(this->t0);
Geom::Point hat2;
- for (t = spiral->t0; t < (1.0 - tstep);) {
- spiral->fitAndDraw(c, dstep, darray, hat1, hat2, &t);
+ double t;
+ for (t = this->t0; t < (1.0 - tstep);) {
+ this->fitAndDraw(c, dstep, darray, hat1, hat2, &t);
hat1 = -hat2;
}
if ((1.0 - t) > SP_EPSILON) {
- spiral->fitAndDraw(c, (1.0 - t) / (SAMPLE_SIZE - 1.0), darray, hat1, hat2, &t);
+ this->fitAndDraw(c, (1.0 - t) / (SAMPLE_SIZE - 1.0), darray, hat1, hat2, &t);
}
/* Reset the shape'scurve to the "original_curve"
@@ -388,7 +385,7 @@ void SPSpiral::set_shape() {
bool success = sp_lpe_item_perform_path_effect(this, c_lpe);
if (success) {
- shape->setCurveInsync( c_lpe, TRUE);
+ this->setCurveInsync( c_lpe, TRUE);
}
c_lpe->unref();
@@ -593,17 +590,17 @@ bool SPSpiral::isInvalid() const {
if (rad < 0.0 || rad > SP_HUGE) {
g_print("rad(t=0)=%g\n", rad);
- return TRUE;
+ return true;
}
this->getPolar(1.0, &rad, NULL);
if (rad < 0.0 || rad > SP_HUGE) {
g_print("rad(t=1)=%g\n", rad);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
/*
diff --git a/src/sp-spiral.h b/src/sp-spiral.h
index a81b4a3dd..4e067981b 100644
--- a/src/sp-spiral.h
+++ b/src/sp-spiral.h
@@ -20,8 +20,8 @@
#define SP_HUGE 1e5
#define SPIRAL_TOLERANCE 3.0
-#define SAMPLE_STEP (1.0/4.0) ///< step per 2PI
-#define SAMPLE_SIZE 8 ///< sample size per one bezier
+#define SAMPLE_STEP (1.0/4.0) ///< step per 2PI
+#define SAMPLE_SIZE 8 ///< sample size per one bezier
#define SP_SPIRAL(obj) (dynamic_cast<SPSpiral*>((SPObject*)obj))
@@ -61,11 +61,6 @@ public:
bool isInvalid() const;
-//private:
- Geom::Point getTangent(gdouble t) const;
-
- void fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom::Point const& hat1, Geom::Point& hat2, double* t) const;
-
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags);
virtual void update(SPCtx *ctx, guint flags);
@@ -77,6 +72,10 @@ public:
virtual void set_shape();
virtual void update_patheffect(bool write);
+
+private:
+ Geom::Point getTangent(gdouble t) const;
+ void fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom::Point const& hat1, Geom::Point& hat2, double* t) const;
};
#endif // SEEN_SP_SPIRAL_H
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index 56cac1981..a558c6bf4 100644
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
@@ -37,12 +37,6 @@
#include "sp-use.h"
#include "sp-use-reference.h"
-/* fixme: */
-static void sp_use_href_changed(SPObject *old_ref, SPObject *ref, SPUse *use);
-static void sp_use_delete_self(SPObject *deleted, SPUse *self);
-
-#include "sp-factory.h"
-
namespace {
SPObject* createUse() {
return new SPUse();
@@ -51,23 +45,20 @@ namespace {
bool useRegistered = SPFactory::instance().registerObject("svg:use", createUse);
}
-SPUse::SPUse() : SPItem() {
- this->child = NULL;
-
+SPUse::SPUse()
+ : SPItem()
+ , child(NULL)
+ , href(NULL)
+ , ref(new SPUseReference(this))
+{
this->x.unset();
this->y.unset();
this->width.unset(SVGLength::PERCENT, 1.0, 1.0);
this->height.unset(SVGLength::PERCENT, 1.0, 1.0);
- this->href = NULL;
-
- //new (&this->_delete_connection) sigc::connection();
- //new (&this->_changed_connection) sigc::connection();
- //new (&this->_transformed_connection) sigc::connection();
-
- this->ref = new SPUseReference(this);
-
- this->_changed_connection = this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_use_href_changed), this));
+ this->_changed_connection = this->ref->changedSignal().connect(
+ sigc::hide(sigc::hide(sigc::mem_fun(this, &SPUse::href_changed)))
+ );
}
SPUse::~SPUse() {
@@ -79,11 +70,6 @@ SPUse::~SPUse() {
this->ref->detach();
delete this->ref;
this->ref = 0;
-
- //this->_delete_connection.~connection();
- //this->_changed_connection.~connection();
-
- //this->_transformed_connection.~connection();
}
void SPUse::build(SPDocument *document, Inkscape::XML::Node *repr) {
@@ -195,12 +181,8 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM
Geom::OptRect SPUse::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) {
Geom::OptRect bbox;
- if (this->child && SP_IS_ITEM(this->child)) {
- SPItem *child = SP_ITEM(this->child);
- Geom::Affine const ct( child->transform
- * Geom::Translate(this->x.computed,
- this->y.computed)
- * transform );
+ if (this->child) {
+ Geom::Affine const ct(child->transform * Geom::Translate(this->x.computed, this->y.computed) * transform );
bbox = child->bounds(bboxtype, ct);
}
@@ -217,8 +199,8 @@ void SPUse::print(SPPrintContext* ctx) {
translated = true;
}
- if (this->child && SP_IS_ITEM(this->child)) {
- SP_ITEM(this->child)->invoke_print(ctx);
+ if (this->child) {
+ this->child->invoke_print(ctx);
}
if (translated) {
@@ -227,16 +209,17 @@ void SPUse::print(SPPrintContext* ctx) {
}
const char* SPUse::displayName() {
- if(this->child && SP_IS_SYMBOL( this->child )) {
+ if (this->child && SP_IS_SYMBOL( this->child )) {
return _("Symbol");
}
+
return _("Clone");
}
gchar* SPUse::description() {
if (this->child) {
if( SP_IS_SYMBOL( this->child ) ) {
- return g_strdup_printf(_("called %s"), SP_ITEM(this->child)->title());
+ return g_strdup_printf(_("called %s"), this->child->title());
}
static unsigned recursion_depth = 0;
@@ -250,7 +233,7 @@ gchar* SPUse::description() {
}
++recursion_depth;
- char *child_desc = SP_ITEM(this->child)->detailedDescription();
+ char *child_desc = this->child->detailedDescription();
--recursion_depth;
char *ret = g_strdup_printf(_("of: %s"), child_desc);
@@ -268,7 +251,8 @@ Inkscape::DrawingItem* SPUse::show(Inkscape::Drawing &drawing, unsigned int key,
ai->setStyle(this->style);
if (this->child) {
- Inkscape::DrawingItem *ac = SP_ITEM(this->child)->invoke_show(drawing, key, flags);
+ Inkscape::DrawingItem *ac = this->child->invoke_show(drawing, key, flags);
+
if (ac) {
ai->prependChild(ac);
}
@@ -282,7 +266,7 @@ Inkscape::DrawingItem* SPUse::show(Inkscape::Drawing &drawing, unsigned int key,
void SPUse::hide(unsigned int key) {
if (this->child) {
- SP_ITEM(this->child)->invoke_hide(key);
+ this->child->invoke_hide(key);
}
// SPItem::onHide(key);
@@ -297,38 +281,42 @@ void SPUse::hide(unsigned int key) {
* Note that the returned is the clone object, i.e. the child of an SPUse (of the argument one for
* the trivial case) and not the "true original".
*/
-SPItem *
-sp_use_root(SPUse *use)
-{
- SPObject *orig = use->child;
+SPItem *SPUse::root() {
+ SPItem *orig = this->child;
+
while (orig && SP_IS_USE(orig)) {
orig = SP_USE(orig)->child;
}
- if (!orig || !SP_IS_ITEM(orig))
+
+ if (!orig) {
return NULL;
- return SP_ITEM(orig);
+ }
+
+ return orig;
}
/**
* Returns the effective transform that goes from the ultimate original to given SPUse, both ends
* included.
*/
-Geom::Affine
-sp_use_get_root_transform(SPUse *use)
-{
+Geom::Affine SPUse::get_root_transform() {
//track the ultimate source of a chain of uses
- SPObject *orig = use->child;
+ SPObject *orig = this->child;
+
GSList *chain = NULL;
- chain = g_slist_prepend(chain, use);
+ chain = g_slist_prepend(chain, this);
+
while (SP_IS_USE(orig)) {
chain = g_slist_prepend(chain, orig);
orig = SP_USE(orig)->child;
}
+
chain = g_slist_prepend(chain, orig);
- //calculate the accummulated transform, starting from the original
+ // calculate the accummulated transform, starting from the original
Geom::Affine t(Geom::identity());
+
for (GSList *i = chain; i != NULL; i = i->next) {
SPItem *i_tem = SP_ITEM(i->data);
@@ -337,6 +325,7 @@ sp_use_get_root_transform(SPUse *use)
// represent the values of the x and y attributes on the 'use' element." - http://www.w3.org/TR/SVG11/struct.html#UseElement
if (SP_IS_USE(i_tem)) {
SPUse *i_use = SP_USE(i_tem);
+
if ((i_use->x._set && i_use->x.computed != 0) || (i_use->y._set && i_use->y.computed != 0)) {
t = t * Geom::Translate(i_use->x._set ? i_use->x.computed : 0, i_use->y._set ? i_use->y.computed : 0);
}
@@ -353,16 +342,14 @@ sp_use_get_root_transform(SPUse *use)
* Returns the transform that leads to the use from its immediate original.
* Does not inlcude the original's transform if any.
*/
-Geom::Affine
-sp_use_get_parent_transform(SPUse *use)
-{
+Geom::Affine SPUse::get_parent_transform() {
Geom::Affine t(Geom::identity());
- if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) {
- t *= Geom::Translate(use->x._set ? use->x.computed : 0,
- use->y._set ? use->y.computed : 0);
+
+ if ((this->x._set && this->x.computed != 0) || (this->y._set && this->y.computed != 0)) {
+ t *= Geom::Translate(this->x._set ? this->x.computed : 0, this->y._set ? this->y.computed : 0);
}
- t *= SP_ITEM(use)->transform;
+ t *= this->transform;
return t;
}
@@ -371,17 +358,15 @@ sp_use_get_parent_transform(SPUse *use)
* that the clone stays unmoved or moves in parallel (depending on user setting) regardless of the
* clone's transform.
*/
-static void
-sp_use_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPUse *self)
-{
+void SPUse::move_compensate(Geom::Affine const *mp) {
// the clone is orphaned; or this is not a real use, but a clone of another use;
// we skip it, otherwise duplicate compensation will occur
- if (self->cloned) {
+ if (this->cloned) {
return;
}
// never compensate uses which are used in flowtext
- if (self->parent && SP_IS_FLOWREGION(self->parent)) {
+ if (this->parent && SP_IS_FLOWREGION(this->parent)) {
return;
}
@@ -398,9 +383,9 @@ sp_use_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPUse *self
return;
// restore item->transform field from the repr, in case it was changed by seltrans
- self->readAttr ("transform");
+ this->readAttr ("transform");
- Geom::Affine t = sp_use_get_parent_transform(self);
+ Geom::Affine t = this->get_parent_transform();
Geom::Affine clone_move = t.inverse() * m * t;
// calculate the compensation matrix and the advertized movement matrix
@@ -416,77 +401,63 @@ sp_use_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPUse *self
}
// commit the compensation
- self->transform *= clone_move;
- self->doWriteTransform(self->getRepr(), self->transform, &advertized_move);
- self->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ this->transform *= clone_move;
+ this->doWriteTransform(this->getRepr(), this->transform, &advertized_move);
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
-static void
-sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use)
-{
- SPItem *item = SP_ITEM(use);
-
- use->_delete_connection.disconnect();
- use->_transformed_connection.disconnect();
+void SPUse::href_changed() {
+ this->_delete_connection.disconnect();
+ this->_transformed_connection.disconnect();
- if (use->child) {
- use->detach(use->child);
- use->child = NULL;
+ if (this->child) {
+ this->detach(this->child);
+ this->child = NULL;
}
- if (use->href) {
- SPItem *refobj = use->ref->getObject();
+ if (this->href) {
+ SPItem *refobj = this->ref->getObject();
+
if (refobj) {
Inkscape::XML::Node *childrepr = refobj->getRepr();
-// GType type = sp_repr_type_lookup(childrepr);
-// g_return_if_fail(type > G_TYPE_NONE);
-// if (g_type_is_a(type, SP_TYPE_ITEM)) {
-// use->child = (SPObject*) g_object_new(type, 0);
-// use->attach(use->child, use->lastChild());
-// sp_object_unref(use->child, use);
-// (use->child)->invoke_build(use->document, childrepr, TRUE);
-//
-// for (SPItemView *v = item->display; v != NULL; v = v->next) {
-// Inkscape::DrawingItem *ai;
-// ai = SP_ITEM(use->child)->invoke_show(v->arenaitem->drawing(), v->key, v->flags);
-// if (ai) {
-// v->arenaitem->prependChild(ai);
-// }
-// }
-// }
-
SPObject* obj = SPFactory::instance().createObject(NodeTraits::get_type_string(*childrepr));
+
if (SP_IS_ITEM(obj)) {
- use->child = obj;
+ this->child = SP_ITEM(obj);
- use->attach(use->child, use->lastChild());
- sp_object_unref(use->child, use);
- (use->child)->invoke_build(use->document, childrepr, TRUE);
+ this->attach(this->child, this->lastChild());
+ sp_object_unref(this->child, this);
+
+ this->child->invoke_build(this->document, childrepr, TRUE);
+
+ for (SPItemView *v = this->display; v != NULL; v = v->next) {
+ Inkscape::DrawingItem *ai = this->child->invoke_show(v->arenaitem->drawing(), v->key, v->flags);
- for (SPItemView *v = item->display; v != NULL; v = v->next) {
- Inkscape::DrawingItem *ai;
- ai = SP_ITEM(use->child)->invoke_show(v->arenaitem->drawing(), v->key, v->flags);
if (ai) {
v->arenaitem->prependChild(ai);
}
}
} else {
delete obj;
+ g_warning("Tried to create svg:use from invalid object");
}
- use->_delete_connection = refobj->connectDelete(sigc::bind(sigc::ptr_fun(&sp_use_delete_self), use));
- use->_transformed_connection = SP_ITEM(refobj)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_use_move_compensate), use));
+ this->_delete_connection = refobj->connectDelete(
+ sigc::hide(sigc::mem_fun(this, &SPUse::delete_self))
+ );
+
+ this->_transformed_connection = refobj->connectTransformed(
+ sigc::hide(sigc::mem_fun(this, &SPUse::move_compensate))
+ );
}
}
}
-static void
-sp_use_delete_self(SPObject */*deleted*/, SPUse *self)
-{
+void SPUse::delete_self() {
// always delete uses which are used in flowtext
- if (self->parent && SP_IS_FLOWREGION(self->parent)) {
- self->deleteObject();
+ if (this->parent && SP_IS_FLOWREGION(this->parent)) {
+ this->deleteObject();
return;
}
@@ -495,9 +466,9 @@ sp_use_delete_self(SPObject */*deleted*/, SPUse *self)
SP_CLONE_ORPHANS_UNLINK);
if (mode == SP_CLONE_ORPHANS_UNLINK) {
- sp_use_unlink(self);
+ this->unlink();
} else if (mode == SP_CLONE_ORPHANS_DELETE) {
- self->deleteObject();
+ this->deleteObject();
}
}
@@ -514,7 +485,7 @@ void SPUse::update(SPCtx *ctx, unsigned flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
- for (SPItemView *v = SP_ITEM(this)->display; v != NULL; v = v->next) {
+ for (SPItemView *v = this->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
g->setStyle(this->style);
}
@@ -545,14 +516,10 @@ void SPUse::update(SPCtx *ctx, unsigned flags) {
sp_object_ref(this->child);
if (flags || (this->child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
- if (SP_IS_ITEM(this->child)) {
- SPItem const &chi = *SP_ITEM(this->child);
- cctx.i2doc = chi.transform * ictx->i2doc;
- cctx.i2vp = chi.transform * ictx->i2vp;
- this->child->updateDisplay((SPCtx *)&cctx, flags);
- } else {
- this->child->updateDisplay(ctx, flags);
- }
+ SPItem const &chi = *SP_ITEM(this->child);
+ cctx.i2doc = chi.transform * ictx->i2doc;
+ cctx.i2vp = chi.transform * ictx->i2vp;
+ this->child->updateDisplay((SPCtx *)&cctx, flags);
}
sp_object_unref(this->child);
@@ -574,14 +541,12 @@ void SPUse::modified(unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
- for (SPItemView *v = SP_ITEM(this)->display; v != NULL; v = v->next) {
+ for (SPItemView *v = this->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
g->setStyle(this->style);
}
}
- SPObject *child = this->child;
-
if (child) {
sp_object_ref(child);
@@ -593,30 +558,26 @@ void SPUse::modified(unsigned int flags) {
}
}
-SPItem *sp_use_unlink(SPUse *use)
-{
- if (!use) {
- return NULL;
- }
+SPItem *SPUse::unlink() {
+ Inkscape::XML::Node *repr = this->getRepr();
- Inkscape::XML::Node *repr = use->getRepr();
if (!repr) {
return NULL;
}
Inkscape::XML::Node *parent = repr->parent();
- SPDocument *document = use->document;
+ SPDocument *document = this->document;
Inkscape::XML::Document *xml_doc = document->getReprDoc();
// Track the ultimate source of a chain of uses.
- SPItem *orig = sp_use_root(use);
+ SPItem *orig = this->root();
if (!orig) {
return NULL;
}
// Calculate the accumulated transform, starting from the original.
- Geom::Affine t = sp_use_get_root_transform(use);
+ Geom::Affine t = this->get_root_transform();
Inkscape::XML::Node *copy = NULL;
@@ -639,19 +600,19 @@ SPItem *sp_use_unlink(SPUse *use)
// Merge style from the use.
SPStyle *unli_sty = unlinked->style;
- SPStyle const *use_sty = use->style;
+ SPStyle const *use_sty = this->style;
sp_style_merge_from_dying_parent(unli_sty, use_sty);
sp_style_merge_from_parent(unli_sty, unlinked->parent->style);
unlinked->updateRepr();
// Hold onto our SPObject and repr for now.
- sp_object_ref(use, NULL);
+ sp_object_ref(this, NULL);
Inkscape::GC::anchor(repr);
// Remove ourselves, not propagating delete events to avoid a
// chain-reaction with other elements that might reference us.
- use->deleteObject(false);
+ this->deleteObject(false);
// Give the copy our old id and let go of our old repr.
copy->setAttribute("id", repr->attribute("id"));
@@ -665,10 +626,11 @@ SPItem *sp_use_unlink(SPUse *use)
copy->setAttribute("inkscape:tile-cy", NULL);
// Establish the succession and let go of our object.
- use->setSuccessor(unlinked);
- sp_object_unref(use, NULL);
+ this->setSuccessor(unlinked);
+ sp_object_unref(this, NULL);
SPItem *item = SP_ITEM(unlinked);
+
// Set the accummulated transform.
{
Geom::Affine nomove(Geom::identity());
@@ -679,21 +641,18 @@ SPItem *sp_use_unlink(SPUse *use)
return item;
}
-SPItem *sp_use_get_original(SPUse *use)
-{
+SPItem *SPUse::get_original() {
SPItem *ref = NULL;
- if (use) {
- if (use->ref){
- ref = use->ref->getObject();
+ if (this->ref){
+ ref = this->ref->getObject();
}
- }
return ref;
}
void SPUse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) {
- SPItem *root = sp_use_root(this);
+ SPItem *root = this->root();
if (!root) {
return;
diff --git a/src/sp-use.h b/src/sp-use.h
index 0c53fd486..6a83c384f 100644
--- a/src/sp-use.h
+++ b/src/sp-use.h
@@ -30,7 +30,7 @@ public:
// item built from the original's repr (the visible clone)
// relative to the SPUse itself, it is treated as a child, similar to a grouped item relative to its group
- SPObject *child;
+ SPItem *child;
// SVG attrs
SVGLength x;
@@ -63,12 +63,29 @@ public:
virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
virtual void hide(unsigned int key);
virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
-};
-SPItem *sp_use_unlink (SPUse *use);
-SPItem *sp_use_get_original (SPUse *use);
-Geom::Affine sp_use_get_parent_transform (SPUse *use);
-Geom::Affine sp_use_get_root_transform(SPUse *use);
+ SPItem *root();
+
+ SPItem *unlink();
+ SPItem *get_original();
+ Geom::Affine get_parent_transform();
+ Geom::Affine get_root_transform();
+
+private:
+ void href_changed();
+ void move_compensate(Geom::Affine const *mp);
+ void delete_self();
+};
-SPItem *sp_use_root(SPUse *use);
#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/spray-context.cpp b/src/spray-context.cpp
index 08dc59bce..fd9aff196 100644
--- a/src/spray-context.cpp
+++ b/src/spray-context.cpp
@@ -55,6 +55,7 @@
#include "display/canvas-arena.h"
#include "display/curve.h"
#include "livarot/Shape.h"
+#include <2geom/circle.h>
#include <2geom/transforms.h>
#include "preferences.h"
#include "style.h"
@@ -212,14 +213,11 @@ void SPSprayContext::setup() {
{
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
- SPCurve *c = new SPCurve();
- const double C1 = 0.552;
- c->moveto(-1,0);
- c->curveto(-1, C1, -C1, 1, 0, 1 );
- c->curveto(C1, 1, 1, C1, 1, 0 );
- c->curveto(1, -C1, C1, -1, 0, -1 );
- c->curveto(-C1, -1, -1, -C1, -1, 0 );
- c->closepath();
+ Geom::PathVector path;
+ Geom::Circle(0, 0, 1).getPath(path);
+
+ SPCurve *c = new SPCurve(path);
+
this->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c);
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->dilate_area), 0x00000000,(SPWindRule)0);
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index cfd1effcc..a8841985d 100644
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -74,6 +74,7 @@
#include "display/curve.h"
#include "livarot/Shape.h"
#include <2geom/transforms.h>
+#include <2geom/circle.h>
#include "preferences.h"
#include "style.h"
#include "box3d.h"
@@ -271,14 +272,11 @@ void SPTweakContext::setup() {
{
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
- SPCurve *c = new SPCurve();
- const double C1 = 0.552;
- c->moveto(-1,0);
- c->curveto(-1, C1, -C1, 1, 0, 1 );
- c->curveto(C1, 1, 1, C1, 1, 0 );
- c->curveto(1, -C1, C1, -1, 0, -1 );
- c->curveto(-C1, -1, -1, -C1, -1, 0 );
- c->closepath();
+ Geom::PathVector path;
+ Geom::Circle(0, 0, 1).getPath(path);
+
+ SPCurve *c = new SPCurve(path);
+
this->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c);
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->dilate_area), 0x00000000,(SPWindRule)0);
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 2319d2c70..e96b57170 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -296,7 +296,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
}
} else if ( SP_IS_USE(item) ) {
// test whether linked object is supported by the CLONE_ORIGINAL LPE
- SPItem *orig = sp_use_get_original( SP_USE(item) );
+ SPItem *orig = SP_USE(item)->get_original();
if ( SP_IS_SHAPE(orig) ||
SP_IS_TEXT(orig) )
{
@@ -433,7 +433,7 @@ LivePathEffectEditor::onAdd()
// convert to path, apply CLONE_ORIGINAL LPE, link it to the cloned path
// test whether linked object is supported by the CLONE_ORIGINAL LPE
- SPItem *orig = sp_use_get_original( SP_USE(item) );
+ SPItem *orig = SP_USE(item)->get_original();
if ( SP_IS_SHAPE(orig) ||
SP_IS_TEXT(orig) )
{
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index dac67295a..1add4d176 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -1438,7 +1438,7 @@ void PathManipulator::_setGeometry()
if (_path->getRepr()->attribute("inkscape:original-d"))
_path->set_original_curve(_spcurve, false, false);
else
- SP_SHAPE(_path)->setCurve(_spcurve, false);
+ _path->setCurve(_spcurve, false);
}
}