summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-04-10 18:44:21 +0000
committerMarkus Engel <markus.engel@tum.de>2013-04-10 18:44:21 +0000
commit1f096398da95ef2c74a89e53c64d9cd75911b6eb (patch)
tree58b963c4ea018649d68d1112134cc85de5fec564 /src
parentRemoved unused (ancient!) code. (diff)
downloadinkscape-1f096398da95ef2c74a89e53c64d9cd75911b6eb.tar.gz
inkscape-1f096398da95ef2c74a89e53c64d9cd75911b6eb.zip
various little changes
(bzr r11608.1.93)
Diffstat (limited to 'src')
-rw-r--r--src/sp-object.h3
-rw-r--r--src/sp-rect.cpp45
-rw-r--r--src/sp-rect.h32
-rw-r--r--src/svg/svg-length.h7
4 files changed, 60 insertions, 27 deletions
diff --git a/src/sp-object.h b/src/sp-object.h
index cb264a16c..c9e7bbace 100644
--- a/src/sp-object.h
+++ b/src/sp-object.h
@@ -204,6 +204,9 @@ public:
SPObject *next; /* Next object in linked list */
private:
+ SPObject(const SPObject&);
+ SPObject& operator=(const SPObject&);
+
gchar *id; /* Our very own unique id */
Inkscape::XML::Node *repr; /* Our xml representation */
public:
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index 820f05dff..c150267fc 100644
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
@@ -34,7 +34,11 @@
#include "sp-factory.h"
namespace {
- bool rectRegistered = SPFactory::instance().registerObject("svg:rect", []() { return new SPRect(); });
+ SPRect* createRect() {
+ return new SPRect();
+ }
+
+ bool rectRegistered = SPFactory::instance().registerObject("svg:rect", createRect);
}
@@ -200,14 +204,30 @@ void SPRect::set_shape() {
*/
if ((rx > 1e-18) && (ry > 1e-18)) {
c->moveto(x + rx, y);
- if (rx < w2) c->lineto(x + w - rx, y);
- c->curveto(x + w - rx * (1 - C1), y, x + w, y + ry * (1 - C1), x + w, y + ry);
- if (ry < h2) c->lineto(x + w, y + h - ry);
- c->curveto(x + w, y + h - ry * (1 - C1), x + w - rx * (1 - C1), y + h, x + w - rx, y + h);
- if (rx < w2) c->lineto(x + rx, y + h);
- c->curveto(x + rx * (1 - C1), y + h, x, y + h - ry * (1 - C1), x, y + h - ry);
- if (ry < h2) c->lineto(x, y + ry);
- c->curveto(x, y + ry * (1 - C1), x + rx * (1 - C1), y, x + rx, y);
+
+ if (rx < w2) {
+ c->lineto(x + w - rx, y);
+ }
+
+ c->curveto(x + w - rx * (1 - C1), y, x + w, y + ry * (1 - C1), x + w, y + ry);
+
+ if (ry < h2) {
+ c->lineto(x + w, y + h - ry);
+ }
+
+ c->curveto(x + w, y + h - ry * (1 - C1), x + w - rx * (1 - C1), y + h, x + w - rx, y + h);
+
+ if (rx < w2) {
+ c->lineto(x + rx, y + h);
+ }
+
+ c->curveto(x + rx * (1 - C1), y + h, x, y + h - ry * (1 - C1), x, y + h - ry);
+
+ if (ry < h2) {
+ c->lineto(x, y + ry);
+ }
+
+ c->curveto(x, y + ry * (1 - C1), x + rx * (1 - C1), y, x + rx, y);
} else {
c->moveto(x + 0.0, y + 0.0);
c->lineto(x + w, y + 0.0);
@@ -216,8 +236,8 @@ void SPRect::set_shape() {
}
c->closepath();
- this->setCurveInsync( c, TRUE);
- this->setCurveBeforeLPE( c );
+ this->setCurveInsync(c, true);
+ this->setCurveBeforeLPE(c);
// LPE is not applied because result can generally not be represented as SPRect
@@ -504,7 +524,8 @@ void SPRect::convert_to_guides() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (!prefs->getBool("/tools/shapes/rect/convertguides", true)) {
- this->convert_to_guides();
+ // Use bounding box instead of edges
+ SPShape::convert_to_guides();
return;
}
diff --git a/src/sp-rect.h b/src/sp-rect.h
index 36942015a..c04d57660 100644
--- a/src/sp-rect.h
+++ b/src/sp-rect.h
@@ -27,36 +27,28 @@ public:
SPRect();
virtual ~SPRect();
- SVGLength x;
- SVGLength y;
- SVGLength width;
- SVGLength height;
- SVGLength rx;
- SVGLength ry;
-
void setPosition(gdouble x, gdouble y, gdouble width, gdouble height);
/* If SET if FALSE, VALUE is just ignored */
void setRx(bool set, gdouble value);
void setRy(bool set, gdouble value);
- void setVisibleRx(gdouble rx);
- void setVisibleRy(gdouble ry);
gdouble getVisibleRx() const;
+ void setVisibleRx(gdouble rx);
+
gdouble getVisibleRy() const;
+ void setVisibleRy(gdouble ry);
+
Geom::Rect getRect() const;
- void setVisibleWidth(gdouble rx);
- void setVisibleHeight(gdouble ry);
gdouble getVisibleWidth() const;
+ void setVisibleWidth(gdouble rx);
+
gdouble getVisibleHeight() const;
+ void setVisibleHeight(gdouble ry);
void compensateRxRy(Geom::Affine xform);
-private:
- static gdouble vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform);
-
-public:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
void set(unsigned key, gchar const *value);
@@ -70,6 +62,16 @@ public:
void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
void convert_to_guides();
+
+ SVGLength x;
+ SVGLength y;
+ SVGLength width;
+ SVGLength height;
+ SVGLength rx;
+ SVGLength ry;
+
+private:
+ static gdouble vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform);
};
#endif // SEEN_SP_RECT_H
diff --git a/src/svg/svg-length.h b/src/svg/svg-length.h
index 6c8f1e1dd..3832a4eb5 100644
--- a/src/svg/svg-length.h
+++ b/src/svg/svg-length.h
@@ -37,9 +37,16 @@ public:
LAST_UNIT = PERCENT
};
+ // The object's value is valid / exists in SVG.
bool _set;
+
+ // The unit of value.
Unit unit;
+
+ // The value of this SVGLength as found in the SVG.
float value;
+
+ // The value in pixels (value * pixels/unit).
float computed;
float operator=(float v) {