summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-08-28 22:53:56 +0000
committerKrzysztof Kosinski <tweenk.pl@gmail.com>2011-08-28 22:53:56 +0000
commitf4b79d4a8edc870f099fb9194c8493ec04012ad1 (patch)
tree2951d5171168abc288c00d09d04f5e5737e779d5 /src
parentTie the snapping of rectangle corners and quadrant points of ellipses to the ... (diff)
parentCompletely remove libnr (diff)
downloadinkscape-f4b79d4a8edc870f099fb9194c8493ec04012ad1.tar.gz
inkscape-f4b79d4a8edc870f099fb9194c8493ec04012ad1.zip
Completely remove libnr
(bzr r10589)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/affine.cpp60
-rw-r--r--src/2geom/coord.h42
-rw-r--r--src/2geom/forward.h4
-rw-r--r--src/2geom/generic-interval.h31
-rw-r--r--src/2geom/generic-rect.h36
-rw-r--r--src/2geom/interval.h43
-rw-r--r--src/2geom/linear.h2
-rw-r--r--src/2geom/rect.h42
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/conn-avoid-ref.cpp2
-rw-r--r--src/desktop.cpp72
-rw-r--r--src/desktop.h7
-rw-r--r--src/dialogs/clonetiler.cpp7
-rw-r--r--src/dialogs/export.cpp29
-rw-r--r--src/dialogs/spellcheck.cpp4
-rw-r--r--src/display/canvas-arena.cpp8
-rw-r--r--src/display/canvas-arena.h2
-rw-r--r--src/display/canvas-axonomgrid.cpp66
-rw-r--r--src/display/canvas-bpath.cpp4
-rw-r--r--src/display/canvas-grid.cpp85
-rw-r--r--src/display/canvas-text.cpp4
-rw-r--r--src/display/drawing-group.cpp3
-rw-r--r--src/display/drawing-item.cpp4
-rw-r--r--src/display/drawing-shape.cpp1
-rw-r--r--src/display/guideline.cpp38
-rw-r--r--src/display/nr-3dutils.h2
-rw-r--r--src/display/nr-filter-colormatrix.cpp4
-rw-r--r--src/display/nr-filter-colormatrix.h1
-rw-r--r--src/display/nr-filter-component-transfer.cpp4
-rw-r--r--src/display/nr-filter-component-transfer.h1
-rw-r--r--src/display/nr-filter-convolve-matrix.cpp11
-rw-r--r--src/display/nr-filter-convolve-matrix.h3
-rw-r--r--src/display/nr-filter-diffuselighting.cpp8
-rw-r--r--src/display/nr-filter-diffuselighting.h2
-rw-r--r--src/display/nr-filter-displacement-map.cpp7
-rw-r--r--src/display/nr-filter-displacement-map.h3
-rw-r--r--src/display/nr-filter-flood.cpp5
-rw-r--r--src/display/nr-filter-flood.h1
-rw-r--r--src/display/nr-filter-gaussian.cpp7
-rw-r--r--src/display/nr-filter-gaussian.h2
-rw-r--r--src/display/nr-filter-image.cpp3
-rw-r--r--src/display/nr-filter-morphology.cpp7
-rw-r--r--src/display/nr-filter-morphology.h2
-rw-r--r--src/display/nr-filter-offset.cpp17
-rw-r--r--src/display/nr-filter-offset.h3
-rw-r--r--src/display/nr-filter-primitive.cpp2
-rw-r--r--src/display/nr-filter-primitive.h5
-rw-r--r--src/display/nr-filter-slot.h2
-rw-r--r--src/display/nr-filter-specularlighting.cpp9
-rw-r--r--src/display/nr-filter-specularlighting.h2
-rw-r--r--src/display/nr-filter-tile.cpp5
-rw-r--r--src/display/nr-filter-tile.h1
-rw-r--r--src/display/nr-filter-turbulence.cpp1
-rw-r--r--src/display/nr-filter-turbulence.h1
-rw-r--r--src/display/nr-filter-units.cpp1
-rw-r--r--src/display/nr-filter-units.h1
-rw-r--r--src/display/nr-filter.cpp4
-rw-r--r--src/display/nr-filter.h1
-rw-r--r--src/display/nr-style.cpp7
-rw-r--r--src/display/sodipodi-ctrl.cpp28
-rw-r--r--src/display/sodipodi-ctrl.h3
-rw-r--r--src/display/sodipodi-ctrlrect.cpp2
-rw-r--r--src/display/sp-canvas-util.cpp9
-rw-r--r--src/display/sp-canvas.cpp154
-rw-r--r--src/display/sp-canvas.h8
-rw-r--r--src/display/sp-ctrlline.cpp4
-rw-r--r--src/display/sp-ctrlpoint.cpp2
-rw-r--r--src/display/sp-ctrlquadr.cpp4
-rw-r--r--src/document.cpp46
-rw-r--r--src/document.h1
-rw-r--r--src/dropper-context.cpp16
-rw-r--r--src/dyna-draw-context.cpp6
-rw-r--r--src/eraser-context.cpp4
-rw-r--r--src/extension/dbus/document-interface.cpp10
-rw-r--r--src/extension/effect.cpp18
-rw-r--r--src/extension/effect.h4
-rw-r--r--src/extension/implementation/implementation.cpp174
-rw-r--r--src/extension/implementation/implementation.h94
-rw-r--r--src/extension/internal/bitmap/crop.cpp2
-rw-r--r--src/extension/internal/cairo-render-context.cpp124
-rw-r--r--src/extension/internal/cairo-render-context.h26
-rw-r--r--src/extension/internal/cairo-renderer.cpp123
-rw-r--r--src/extension/internal/emf-win32-print.cpp39
-rw-r--r--src/extension/internal/emf-win32-print.h18
-rw-r--r--src/extension/internal/grid.cpp2
-rw-r--r--src/extension/internal/latex-pstricks.cpp28
-rw-r--r--src/extension/internal/latex-pstricks.h16
-rw-r--r--src/extension/internal/latex-text-renderer.cpp26
-rw-r--r--src/extension/internal/odf.cpp15
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp1
-rw-r--r--src/extension/print.cpp38
-rw-r--r--src/extension/print.h22
-rw-r--r--src/file.cpp2
-rw-r--r--src/filter-chemistry.cpp4
-rw-r--r--src/flood-context.cpp2
-rw-r--r--src/gradient-chemistry.cpp20
-rw-r--r--src/gradient-context.cpp5
-rw-r--r--src/gradient-drag.cpp45
-rw-r--r--src/gradient-drag.h1
-rw-r--r--src/graphlayout.cpp6
-rw-r--r--src/helper/action.cpp185
-rw-r--r--src/helper/action.h51
-rw-r--r--src/helper/geom.cpp1
-rw-r--r--src/inkview.cpp1
-rw-r--r--src/interface.cpp39
-rw-r--r--src/knotholder.h1
-rw-r--r--src/libnr/CMakeLists.txt33
-rw-r--r--src/libnr/Makefile_insert23
-rw-r--r--src/libnr/in-svg-plane-test.h82
-rw-r--r--src/libnr/in-svg-plane.h32
-rw-r--r--src/libnr/makefile.in17
-rw-r--r--src/libnr/nr-convert2geom.h34
-rw-r--r--src/libnr/nr-forward.h28
-rw-r--r--src/libnr/nr-macros.h61
-rw-r--r--src/libnr/nr-object.cpp318
-rw-r--r--src/libnr/nr-object.h157
-rw-r--r--src/libnr/nr-point-fns.cpp62
-rw-r--r--src/libnr/nr-point-fns.h23
-rw-r--r--src/libnr/nr-rect-l.cpp59
-rw-r--r--src/libnr/nr-rect-l.h28
-rw-r--r--src/libnr/nr-rect.cpp203
-rw-r--r--src/libnr/nr-rect.h91
-rw-r--r--src/libnr/nr-values.cpp18
-rw-r--r--src/libnr/nr-values.h43
-rw-r--r--src/libnrtype/FontInstance.cpp1
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp37
-rw-r--r--src/libnrtype/Layout-TNG.h7
-rw-r--r--src/libnrtype/font-instance.h2
-rw-r--r--src/libnrtype/nr-type-primitives.cpp1
-rw-r--r--src/livarot/Path.h2
-rw-r--r--src/livarot/PathConversion.cpp279
-rw-r--r--src/livarot/PathCutting.cpp1
-rw-r--r--src/livarot/PathOutline.cpp1
-rw-r--r--src/livarot/Shape.cpp1
-rw-r--r--src/livarot/ShapeRaster.cpp1
-rw-r--r--src/livarot/sweep-tree.cpp1
-rw-r--r--src/live_effects/lpe-curvestitch.cpp1
-rw-r--r--src/live_effects/lpe-extrude.cpp6
-rw-r--r--src/live_effects/lpe-mirror_symmetry.cpp4
-rw-r--r--src/live_effects/lpe-rough-hatches.cpp3
-rw-r--r--src/live_effects/lpegroupbbox.cpp2
-rw-r--r--src/live_effects/parameter/parameter.cpp1
-rw-r--r--src/live_effects/parameter/random.cpp1
-rw-r--r--src/main.cpp9
-rw-r--r--src/marker.cpp54
-rw-r--r--src/object-snapper.cpp20
-rw-r--r--src/pencil-context.cpp3
-rw-r--r--src/print.cpp21
-rw-r--r--src/print.h12
-rw-r--r--src/removeoverlap.cpp2
-rw-r--r--src/satisfied-guide-cns.cpp1
-rw-r--r--src/selcue.cpp10
-rw-r--r--src/selection-chemistry.cpp45
-rw-r--r--src/selection.cpp46
-rw-r--r--src/selection.h23
-rw-r--r--src/seltrans.cpp30
-rw-r--r--src/seltrans.h2
-rw-r--r--src/snap.cpp6
-rw-r--r--src/sp-clippath.cpp53
-rw-r--r--src/sp-clippath.h5
-rw-r--r--src/sp-ellipse.cpp25
-rw-r--r--src/sp-flowtext.cpp65
-rw-r--r--src/sp-gradient.cpp12
-rw-r--r--src/sp-guide.cpp18
-rw-r--r--src/sp-image.cpp27
-rw-r--r--src/sp-item-group.cpp19
-rw-r--r--src/sp-item-group.h2
-rw-r--r--src/sp-item-transform.cpp2
-rw-r--r--src/sp-item.cpp325
-rw-r--r--src/sp-item.h36
-rw-r--r--src/sp-line.cpp4
-rw-r--r--src/sp-mask.cpp32
-rw-r--r--src/sp-mask.h14
-rw-r--r--src/sp-namedview.cpp5
-rw-r--r--src/sp-offset.cpp2
-rw-r--r--src/sp-paint-server.cpp9
-rw-r--r--src/sp-paint-server.h7
-rw-r--r--src/sp-pattern.cpp37
-rw-r--r--src/sp-pattern.h5
-rw-r--r--src/sp-rect.cpp4
-rw-r--r--src/sp-root.cpp48
-rw-r--r--src/sp-root.h18
-rw-r--r--src/sp-shape.cpp340
-rw-r--r--src/sp-shape.h2
-rw-r--r--src/sp-symbol.cpp66
-rw-r--r--src/sp-symbol.h3
-rw-r--r--src/sp-text.cpp55
-rw-r--r--src/sp-tref.cpp32
-rw-r--r--src/sp-tspan.cpp31
-rw-r--r--src/sp-use.cpp30
-rw-r--r--src/splivarot.cpp4
-rw-r--r--src/spray-context.cpp6
-rw-r--r--src/star-context.cpp1
-rw-r--r--src/svg/svg.h1
-rw-r--r--src/text-chemistry.cpp3
-rw-r--r--src/text-context.cpp4
-rw-r--r--src/text-editing.h1
-rw-r--r--src/tweak-context.cpp20
-rw-r--r--src/ui/clipboard.cpp10
-rw-r--r--src/ui/dialog/align-and-distribute.cpp22
-rw-r--r--src/ui/dialog/align-and-distribute.h4
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp4
-rw-r--r--src/ui/dialog/tile.cpp16
-rw-r--r--src/ui/dialog/transformation.cpp26
-rw-r--r--src/ui/view/view.h1
-rw-r--r--src/ui/widget/style-subject.cpp2
-rw-r--r--src/ui/widget/style-subject.h7
-rw-r--r--src/ui/widget/zoom-status.cpp1
-rw-r--r--src/unclump.cpp4
-rw-r--r--src/verbs.cpp234
-rw-r--r--src/verbs.h4
-rw-r--r--src/widgets/button.cpp62
-rw-r--r--src/widgets/button.h5
-rw-r--r--src/widgets/desktop-widget.cpp12
-rw-r--r--src/widgets/icon.cpp3
-rw-r--r--src/widgets/paint-selector.h10
-rw-r--r--src/widgets/select-toolbar.cpp12
-rw-r--r--src/widgets/stroke-style.cpp3
-rw-r--r--src/widgets/toolbox.cpp31
220 files changed, 1758 insertions, 4199 deletions
diff --git a/src/2geom/affine.cpp b/src/2geom/affine.cpp
index c31b9ba90..1be5d9fe8 100644
--- a/src/2geom/affine.cpp
+++ b/src/2geom/affine.cpp
@@ -144,6 +144,7 @@ bool Affine::isNonzeroTranslation(Coord eps) const {
0 & b & 0 \\
0 & 0 & 1 \end{array}\right]\f$. */
bool Affine::isScale(Coord eps) const {
+ if (isSingular(eps)) return false;
return are_near(_c[1], 0.0, eps) && are_near(_c[2], 0.0, eps) &&
are_near(_c[4], 0.0, eps) && are_near(_c[5], 0.0, eps);
}
@@ -156,6 +157,7 @@ bool Affine::isScale(Coord eps) const {
0 & b & 0 \\
0 & 0 & 1 \end{array}\right]\f$ and \f$a, b \neq 1\f$. */
bool Affine::isNonzeroScale(Coord eps) const {
+ if (isSingular(eps)) return false;
return (!are_near(_c[0], 1.0, eps) || !are_near(_c[3], 1.0, eps)) && //NOTE: these are the diags, and the next line opposite diags
are_near(_c[1], 0.0, eps) && are_near(_c[2], 0.0, eps) &&
are_near(_c[4], 0.0, eps) && are_near(_c[5], 0.0, eps);
@@ -165,11 +167,12 @@ bool Affine::isNonzeroScale(Coord eps) const {
* @param eps Numerical tolerance
* @return True iff the matrix is of the form
* \f$\left[\begin{array}{ccc}
- a & 0 & 0 \\
- 0 & a & 0 \\
- 0 & 0 & 1 \end{array}\right]\f$. */
+ a_1 & 0 & 0 \\
+ 0 & a_2 & 0 \\
+ 0 & 0 & 1 \end{array}\right]\f$ where \f$|a_1| = |a_2|\f$. */
bool Affine::isUniformScale(Coord eps) const {
- return are_near(_c[0], _c[3], eps) &&
+ if (isSingular(eps)) return false;
+ return are_near(fabs(_c[0]), fabs(_c[3]), eps) &&
are_near(_c[1], 0.0, eps) && are_near(_c[2], 0.0, eps) &&
are_near(_c[4], 0.0, eps) && are_near(_c[5], 0.0, eps);
}
@@ -178,11 +181,16 @@ bool Affine::isUniformScale(Coord eps) const {
* @param eps Numerical tolerance
* @return True iff the matrix is of the form
* \f$\left[\begin{array}{ccc}
- a & 0 & 0 \\
- 0 & a & 0 \\
- 0 & 0 & 1 \end{array}\right]\f$ and \f$a \neq 1\f$. */
+ a_1 & 0 & 0 \\
+ 0 & a_2 & 0 \\
+ 0 & 0 & 1 \end{array}\right]\f$ where \f$|a_1| = |a_2|\f$
+ * and \f$a_1, a_2 \neq 1\f$. */
bool Affine::isNonzeroUniformScale(Coord eps) const {
- return !are_near(_c[0], 1.0, eps) && are_near(_c[0], _c[3], eps) &&
+ if (isSingular(eps)) return false;
+ // we need to test both c0 and c3 to handle the case of flips,
+ // which should be treated as nonzero uniform scales
+ return !(are_near(_c[0], 1.0, eps) && are_near(_c[3], 1.0, eps)) &&
+ are_near(fabs(_c[0]), fabs(_c[3]), eps) &&
are_near(_c[1], 0.0, eps) && are_near(_c[2], 0.0, eps) &&
are_near(_c[4], 0.0, eps) && are_near(_c[5], 0.0, eps);
}
@@ -266,15 +274,17 @@ bool Affine::isNonzeroVShear(Coord eps) const {
}
/** @brief Check whether this matrix represents zooming.
- * Zooming is any combination of translation and uniform scaling. It preserves angles, ratios
- * of distances between arbitrary points and unit vectors of line segments.
+ * Zooming is any combination of translation and uniform non-flipping scaling.
+ * It preserves angles, ratios of distances between arbitrary points
+ * and unit vectors of line segments.
* @param eps Numerical tolerance
- * @return True iff the matrix is of the form
+ * @return True iff the matrix is invertible and of the form
* \f$\left[\begin{array}{ccc}
a & 0 & 0 \\
0 & a & 0 \\
b & c & 1 \end{array}\right]\f$. */
bool Affine::isZoom(Coord eps) const {
+ if (isSingular(eps)) return false;
return are_near(_c[0], _c[3], eps) && are_near(_c[1], 0, eps) && are_near(_c[2], 0, eps);
}
@@ -290,30 +300,42 @@ bool Affine::preservesArea(Coord eps) const
}
/** @brief Check whether the transformation preserves angles between lines.
- * This means that the transformation can be any combination of translation, uniform scaling
- * and rotation.
+ * This means that the transformation can be any combination of translation, uniform scaling,
+ * rotation and flipping.
* @param eps Numerical tolerance
* @return True iff the matrix is of the form
* \f$\left[\begin{array}{ccc}
- a & b & 0 \\
- -b & a & 0 \\
- c & d & 1 \end{array}\right]\f$. */
+ a & b & 0 \\
+ -b & a & 0 \\
+ c & d & 1 \end{array}\right]\f$ or
+ \f$\left[\begin{array}{ccc}
+ -a & b & 0 \\
+ b & a & 0 \\
+ c & d & 1 \end{array}\right]\f$. */
bool Affine::preservesAngles(Coord eps) const
{
- return are_near(_c[0], _c[3], eps) && are_near(_c[1], -_c[2], eps);
+ if (isSingular(eps)) return false;
+ return (are_near(_c[0], _c[3], eps) && are_near(_c[1], -_c[2], eps)) ||
+ (are_near(_c[0], -_c[3], eps) && are_near(_c[1], _c[2], eps));
}
/** @brief Check whether the transformation preserves distances between points.
- * This means that the transformation can be any combination of translation and rotation.
+ * This means that the transformation can be any combination of translation,
+ * rotation and flipping.
* @param eps Numerical tolerance
* @return True iff the matrix is of the form
* \f$\left[\begin{array}{ccc}
a & b & 0 \\
-b & a & 0 \\
+ c & d & 1 \end{array}\right]\f$ or
+ \f$\left[\begin{array}{ccc}
+ -a & b & 0 \\
+ b & a & 0 \\
c & d & 1 \end{array}\right]\f$ and \f$a^2 + b^2 = 1\f$. */
bool Affine::preservesDistances(Coord eps) const
{
- return are_near(_c[0], _c[3], eps) && are_near(_c[1], -_c[2], eps) &&
+ return ((are_near(_c[0], _c[3], eps) && are_near(_c[1], -_c[2], eps)) ||
+ (are_near(_c[0], -_c[3], eps) && are_near(_c[1], _c[2], eps))) &&
are_near(_c[0] * _c[0] + _c[1] * _c[1], 1.0, eps);
}
diff --git a/src/2geom/coord.h b/src/2geom/coord.h
index 90e776665..78a852f32 100644
--- a/src/2geom/coord.h
+++ b/src/2geom/coord.h
@@ -75,18 +75,18 @@ struct CoordTraits<IntCoord> {
typedef OptIntRect OptRectType;
typedef
- boost::equality_comparable< IntervalType
- , boost::additive< IntervalType
- , boost::additive< IntervalType, IntCoord
- , boost::orable< IntervalType
+ boost::equality_comparable< IntInterval
+ , boost::additive< IntInterval
+ , boost::additive< IntInterval, IntCoord
+ , boost::orable< IntInterval
> > > >
IntervalOps;
typedef
- boost::equality_comparable< RectType
- , boost::orable< RectType
- , boost::orable< RectType, OptRectType
- , boost::additive< RectType, PointType
+ boost::equality_comparable< IntRect
+ , boost::orable< IntRect
+ , boost::orable< IntRect, OptIntRect
+ , boost::additive< IntRect, IntPoint
> > > >
RectOps;
};
@@ -100,21 +100,23 @@ struct CoordTraits<Coord> {
typedef OptRect OptRectType;
typedef
- boost::equality_comparable< IntervalType
- , boost::additive< IntervalType
- , boost::multipliable< IntervalType
- , boost::orable< IntervalType
- , boost::arithmetic< IntervalType, Coord
- > > > > >
+ boost::equality_comparable< Interval
+ , boost::equality_comparable< Interval, IntInterval
+ , boost::additive< Interval
+ , boost::multipliable< Interval
+ , boost::orable< Interval
+ , boost::arithmetic< Interval, Coord
+ > > > > > >
IntervalOps;
typedef
- boost::equality_comparable< RectType
- , boost::orable< RectType
- , boost::orable< RectType, OptRectType
- , boost::additive< RectType, PointType
- , boost::multipliable< RectType, Affine
- > > > > >
+ boost::equality_comparable< Rect
+ , boost::equality_comparable< Rect, IntRect
+ , boost::orable< Rect
+ , boost::orable< Rect, OptRect
+ , boost::additive< Rect, Point
+ , boost::multipliable< Rect, Affine
+ > > > > > >
RectOps;
};
diff --git a/src/2geom/forward.h b/src/2geom/forward.h
index 0dbd9fa94..70cac1f7d 100644
--- a/src/2geom/forward.h
+++ b/src/2geom/forward.h
@@ -49,13 +49,13 @@ class Ray;
template <typename> class GenericInterval;
template <typename> class GenericOptInterval;
class Interval;
-typedef GenericOptInterval<Coord> OptInterval;
+class OptInterval;
typedef GenericInterval<IntCoord> IntInterval;
typedef GenericOptInterval<IntCoord> OptIntInterval;
template <typename> class GenericRect;
template <typename> class GenericOptRect;
class Rect;
-typedef GenericOptRect<Coord> OptRect;
+class OptRect;
typedef GenericRect<IntCoord> IntRect;
typedef GenericOptRect<IntCoord> OptIntRect;
diff --git a/src/2geom/generic-interval.h b/src/2geom/generic-interval.h
index 0212da676..87d3be2c1 100644
--- a/src/2geom/generic-interval.h
+++ b/src/2geom/generic-interval.h
@@ -49,6 +49,7 @@ template <typename C>
class GenericInterval
: CoordTraits<C>::IntervalOps
{
+ typedef typename CoordTraits<C>::IntervalType CInterval;
typedef GenericInterval<C> Self;
protected:
C _b[2];
@@ -76,15 +77,15 @@ public:
* @param end End of the range
* @return Interval that contains all values from [start, end). */
template <typename InputIterator>
- static Self from_range(InputIterator start, InputIterator end) {
+ static CInterval from_range(InputIterator start, InputIterator end) {
assert(start != end);
- Self result(*start++);
+ CInterval result(*start++);
for (; start != end; ++start) result.expandTo(*start);
return result;
}
/** @brief Create an interval from a C-style array of values it should contain. */
- static Self from_array(C const *c, unsigned n) {
- Self result = from_range(c, c+n);
+ static CInterval from_array(C const *c, unsigned n) {
+ CInterval result = from_range(c, c+n);
return result;
}
/// @}
@@ -94,7 +95,7 @@ public:
C min() const { return _b[0]; }
C max() const { return _b[1]; }
C extent() const { return max() - min(); }
- C middle() const { return (max() + min()) * 0.5; }
+ C middle() const { return (max() + min()) / 2; }
bool isSingular() const { return min() == max(); }
/// @}
@@ -105,11 +106,11 @@ public:
return min() <= val && val <= max();
}
/** @brief Check whether the interval includes the given interval. */
- bool contains(Self const &val) const {
+ bool contains(CInterval const &val) const {
return min() <= val.min() && val.max() <= max();
}
/** @brief Check whether the intervals have any common elements. */
- bool intersects(Self const &val) const {
+ bool intersects(CInterval const &val) const {
return contains(val.min()) || contains(val.max()) || val.contains(*this);
}
/// @}
@@ -159,7 +160,7 @@ public:
* The resulting interval will contain all points of both intervals.
* It might also contain some points which didn't belong to either - this happens
* when the intervals did not have any common elements. */
- void unionWith(Self const &a) {
+ void unionWith(CInterval const &a) {
if(a._b[0] < _b[0]) _b[0] = a._b[0];
if(a._b[1] > _b[1]) _b[1] = a._b[1];
}
@@ -187,7 +188,7 @@ public:
/** @brief Add two intervals.
* Sum is defined as the set of points that can be obtained by adding any two values
* from both operands: \f$S = \{x \in A, y \in B: x + y\}\f$ */
- Self &operator+=(Self const &o) {
+ Self &operator+=(CInterval const &o) {
_b[0] += o._b[0];
_b[1] += o._b[1];
return *this;
@@ -196,7 +197,7 @@ public:
* Difference is defined as the set of points that can be obtained by subtracting
* any value from the second operand from any value from the first operand:
* \f$S = \{x \in A, y \in B: x - y\}\f$ */
- Self &operator-=(Self const &o) {
+ Self &operator-=(CInterval const &o) {
// equal to *this += -o
_b[0] -= o._b[1];
_b[1] -= o._b[0];
@@ -205,12 +206,12 @@ public:
/** @brief Union two intervals.
* Note that the intersection-and-assignment operator is not defined,
* because the result of an intersection can be empty, while Interval cannot. */
- Self &operator|=(Self const &o) {
+ Self &operator|=(CInterval const &o) {
unionWith(o);
return *this;
}
/** @brief Test for interval equality. */
- bool operator==(Self const &other) const {
+ bool operator==(CInterval const &other) const {
return min() == other.min() && max() == other.max();
}
/// @}
@@ -230,15 +231,15 @@ inline GenericInterval<C> unify(GenericInterval<C> const &a, GenericInterval<C>
template <typename C>
class GenericOptInterval
: public boost::optional<typename CoordTraits<C>::IntervalType>
- , boost::orable< GenericOptInterval<C>, typename CoordTraits<C>::OptIntervalType
- , boost::andable< GenericOptInterval<C>, typename CoordTraits<C>::OptIntervalType
+ , boost::orable< GenericOptInterval<C>
+ , boost::andable< GenericOptInterval<C>
> >
{
typedef typename CoordTraits<C>::IntervalType CInterval;
typedef typename CoordTraits<C>::OptIntervalType OptCInterval;
typedef boost::optional<CInterval> Base;
public:
- /// @name Create optionally empty intervals of integers.
+ /// @name Create optionally empty intervals.
/// @{
/** @brief Create an empty interval. */
GenericOptInterval() : Base() {}
diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h
index efe499809..719b37385 100644
--- a/src/2geom/generic-rect.h
+++ b/src/2geom/generic-rect.h
@@ -135,10 +135,10 @@ public:
/** @brief Get the corner of the rectangle with smallest coordinate values.
* In 2Geom standard coordinate system, this means upper left. */
- CPoint min() const { return CPoint(f[X].min(), f[Y].min()); }
+ CPoint min() const { CPoint p(f[X].min(), f[Y].min()); return p; }
/** @brief Get the corner of the rectangle with largest coordinate values.
* In 2Geom standard coordinate system, this means lower right. */
- CPoint max() const { return CPoint(f[X].max(), f[Y].max()); }
+ CPoint max() const { CPoint p(f[X].max(), f[Y].max()); return p; }
/** @brief Return the n-th corner of the rectangle.
* Returns corners in the direction of growing angles, starting from
* the one given by min(). For the standard coordinate system used
@@ -242,7 +242,15 @@ public:
* half of the width, the X interval will contain only the X coordinate
* of the midpoint; same for height. */
void expandBy(C amount) {
- f[X].expandBy(amount); f[Y].expandBy(amount);
+ expandBy(amount, amount);
+ }
+ /** @brief Expand the rectangle in both directions.
+ * Note that this is different from scaling. Negative values wil shrink the
+ * rectangle. If <code>-x</code> is larger than
+ * half of the width, the X interval will contain only the X coordinate
+ * of the midpoint; same for height. */
+ void expandBy(C x, C y) {
+ f[X].expandBy(x); f[Y].expandBy(y);
}
/** @brief Expand the rectangle by the coordinates of the given point.
* This will expand the width by the X coordinate of the point in both directions
@@ -250,8 +258,8 @@ public:
* shrink the rectangle. If <code>-p[X]</code> is larger than half of the width,
* the X interval will contain only the X coordinate of the midpoint;
* same for height. */
- void expandBy(CPoint const &p) {
- f[X].expandBy(p[X]); f[Y].expandBy(p[Y]);
+ void expandBy(CPoint const &p) {
+ expandBy(p[X], p[Y]);
}
/// @}
@@ -279,7 +287,7 @@ public:
return *this;
}
/** @brief Test for equality of rectangles. */
- bool operator==(GenericRect<C> const &o) const { return f[X] == o[X] && f[Y] == o[Y]; }
+ bool operator==(CRect const &o) const { return f[X] == o[X] && f[Y] == o[Y]; }
/// @}
};
@@ -290,10 +298,12 @@ public:
template <typename C>
class GenericOptRect
: public boost::optional<typename CoordTraits<C>::RectType>
+ , boost::equality_comparable< typename CoordTraits<C>::OptRectType
+ , boost::equality_comparable< typename CoordTraits<C>::OptRectType, typename CoordTraits<C>::RectType
, boost::orable< typename CoordTraits<C>::OptRectType
, boost::andable< typename CoordTraits<C>::OptRectType
, boost::andable< typename CoordTraits<C>::OptRectType, typename CoordTraits<C>::RectType
- > > >
+ > > > > >
{
typedef typename CoordTraits<C>::IntervalType CInterval;
typedef typename CoordTraits<C>::OptIntervalType OptCInterval;
@@ -307,6 +317,7 @@ public:
GenericOptRect() : Base() {}
GenericOptRect(GenericRect<C> const &a) : Base(CRect(a)) {}
GenericOptRect(CPoint const &a, CPoint const &b) : Base(CRect(a, b)) {}
+ GenericOptRect(C x0, C y0, C x1, C y1) : Base(CRect(x0, y0, x1, y1)) {}
/// Creates an empty OptRect when one of the argument intervals is empty.
GenericOptRect(OptCInterval const &x_int, OptCInterval const &y_int) {
if (x_int && y_int) {
@@ -314,6 +325,7 @@ public:
}
// else, stay empty.
}
+
/** @brief Create a rectangle from a range of points.
* The resulting rectangle will contain all ponts from the range.
* If the range contains no points, the result will be an empty rectangle.
@@ -427,6 +439,16 @@ public:
intersectWith(b);
return *this;
}
+ /** @brief Test for equality.
+ * All empty rectangles are equal. */
+ bool operator==(OptCRect const &other) const {
+ if (!*this != !other) return false;
+ return *this ? (**this == *other) : true;
+ }
+ bool operator==(CRect const &other) const {
+ if (!*this) return false;
+ return **this == other;
+ }
/// @}
};
diff --git a/src/2geom/interval.h b/src/2geom/interval.h
index 711eaa5e2..b1fac04d9 100644
--- a/src/2geom/interval.h
+++ b/src/2geom/interval.h
@@ -47,12 +47,6 @@
namespace Geom {
-/**
- * @brief Range of real numbers that can be empty.
- * @ingroup Primitives
- */
-typedef GenericOptInterval<Coord> OptInterval;
-
/**
* @brief Range of real numbers that is never empty.
*
@@ -128,8 +122,6 @@ public:
/// @name Operators
/// @{
- inline operator OptInterval() { return OptInterval(*this); }
-
// IMPL: ScalableConcept
/** @brief Scale an interval */
Interval &operator*=(Coord s) {
@@ -158,6 +150,12 @@ public:
expandTo(mx * o.max());
return *this;
}
+ bool operator==(IntInterval const &ii) const {
+ return min() == Coord(ii.min()) && max() == Coord(ii.max());
+ }
+ bool operator==(Interval const &other) const {
+ return Base::operator==(other);
+ }
/// @}
/// @name Rounding to integer values
@@ -177,6 +175,35 @@ public:
/// @}
};
+/**
+ * @brief Range of real numbers that can be empty.
+ * @ingroup Primitives
+ */
+class OptInterval
+ : public GenericOptInterval<Coord>
+{
+ typedef GenericOptInterval<Coord> Base;
+public:
+ /// @name Create optionally empty intervals.
+ /// @{
+ /** @brief Create an empty interval. */
+ OptInterval() : Base() {}
+ /** @brief Wrap an existing interval. */
+ OptInterval(Interval const &a) : Base(a) {}
+ /** @brief Create an interval containing a single point. */
+ OptInterval(Coord u) : Base(u) {}
+ /** @brief Create an interval containing a range of numbers. */
+ OptInterval(Coord u, Coord v) : Base(u,v) {}
+ OptInterval(Base const &b) : Base(b) {}
+
+ /** @brief Promote from IntInterval. */
+ OptInterval(IntInterval const &i) : Base(Interval(i)) {}
+ /** @brief Promote from OptIntInterval. */
+ OptInterval(OptIntInterval const &i) : Base() {
+ if (i) *this = Interval(*i);
+ }
+};
+
// functions required for Python bindings
inline Interval unify(Interval const &a, Interval const &b)
{
diff --git a/src/2geom/linear.h b/src/2geom/linear.h
index 448ab3bb7..df6dd9904 100644
--- a/src/2geom/linear.h
+++ b/src/2geom/linear.h
@@ -55,7 +55,7 @@ class SBasis;
class Linear{
public:
double a[2];
- Linear() { a[0] = 0; a[1] = 0; }
+ Linear() {}
Linear(double aa, double b) {a[0] = aa; a[1] = b;}
Linear(double aa) {a[0] = aa; a[1] = aa;}
diff --git a/src/2geom/rect.h b/src/2geom/rect.h
index b79a0a04f..2516bcfa6 100644
--- a/src/2geom/rect.h
+++ b/src/2geom/rect.h
@@ -48,12 +48,6 @@
namespace Geom {
/**
- * @brief Axis-aligned rectangle that can be empty.
- * @ingroup Primitives
- */
-typedef GenericOptRect<Coord> OptRect;
-
-/**
* @brief Axis aligned, non-empty rectangle.
* @ingroup Primitives
*/
@@ -118,9 +112,45 @@ public:
/// @name Operators
/// @{
Rect &operator*=(Affine const &m);
+ bool operator==(IntRect const &ir) const {
+ return f[X] == ir[X] && f[Y] == ir[Y];
+ }
+ bool operator==(Rect const &other) const {
+ return Base::operator==(other);
+ }
/// @}
};
+/**
+ * @brief Axis-aligned rectangle that can be empty.
+ * @ingroup Primitives
+ */
+class OptRect
+ : public GenericOptRect<Coord>
+{
+ typedef GenericOptRect<Coord> Base;
+public:
+ OptRect() : Base() {}
+ OptRect(Rect const &a) : Base(a) {}
+ OptRect(Point const &a, Point const &b) : Base(a, b) {}
+ OptRect(Coord x0, Coord y0, Coord x1, Coord y1) : Base(x0, y0, x1, y1) {}
+ OptRect(OptInterval const &x_int, OptInterval const &y_int) : Base(x_int, y_int) {}
+ OptRect(Base const &b) : Base(b) {}
+
+ OptRect(IntRect const &r) : Base(Rect(r)) {}
+ OptRect(OptIntRect const &r) : Base() {
+ if (r) *this = Rect(*r);
+ }
+ // actually, the only reason we have this class, instead of typedefing
+ // to GenericOptRect<Coord>, are the above constructors
+ bool operator==(OptRect const &other) const {
+ return Base::operator==(other);
+ }
+ bool operator==(Rect const &other) const {
+ return Base::operator==(other);
+ }
+};
+
Coord distanceSq(Point const &p, Rect const &rect);
Coord distance(Point const &p, Rect const &rect);
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 038e7bb73..ce289f33c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -550,7 +550,6 @@ add_subdirectory(libcroco)
add_subdirectory(libgdl)
add_subdirectory(libvpsc)
add_subdirectory(livarot)
-add_subdirectory(libnr)
add_subdirectory(libnrtype)
diff --git a/src/Makefile.am b/src/Makefile.am
index 5a50eb36f..2ab4d0030 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -120,7 +120,6 @@ include helper/Makefile_insert
include io/Makefile_insert
include libcroco/Makefile_insert
include libgdl/Makefile_insert
-include libnr/Makefile_insert
include libnrtype/Makefile_insert
include libavoid/Makefile_insert
include livarot/Makefile_insert
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index fad11bb89..331865254 100644
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
@@ -394,7 +394,7 @@ Geom::Point SPAvoidRef::getConnectionPointPos(const int type, const int id)
if ( type == ConnPointDefault )
{
// For now, just default to the centre of the item
- Geom::OptRect bbox = item->getBounds(item->i2doc_affine());
+ Geom::OptRect bbox = item->documentVisualBounds();
pos = (bbox) ? bbox->midpoint() : Geom::Point(0, 0);
}
else
diff --git a/src/desktop.cpp b/src/desktop.cpp
index ca5fdc63b..dc06f773e 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -144,8 +144,6 @@ SPDesktop::SPDesktop() :
page_border( 0 ),
current( 0 ),
_focusMode(false),
- zooms_past( 0 ),
- zooms_future( 0 ),
dkey( 0 ),
number( 0 ),
window_state(0),
@@ -410,9 +408,6 @@ void SPDesktop::destroy()
delete _guides_message_context;
_guides_message_context = NULL;
-
- g_list_free (zooms_past);
- g_list_free (zooms_future);
}
SPDesktop::~SPDesktop() {}
@@ -577,16 +572,16 @@ bool SPDesktop::isLayer(SPObject *object) const {
}
/**
- * True if desktop viewport fully contains \a item's bbox.
+ * True if desktop viewport intersects \a item's bbox.
*/
bool SPDesktop::isWithinViewport (SPItem *item) const
{
Geom::Rect const viewport = get_display_area();
- Geom::OptRect const bbox = item->getBboxDesktop();
+ Geom::OptRect const bbox = item->desktopVisualBounds();
if (bbox) {
- return viewport.contains(*bbox);
+ return viewport.intersects(*bbox);
} else {
- return true;
+ return false;
}
}
@@ -771,25 +766,12 @@ SPDesktop::point() const
* Put current zoom data in history list.
*/
void
-SPDesktop::push_current_zoom (GList **history)
+SPDesktop::push_current_zoom (std::list<Geom::Rect> &history)
{
- Geom::Rect const area = get_display_area();
+ Geom::Rect area = get_display_area();
- NRRect *old_zoom = g_new(NRRect, 1);
- old_zoom->x0 = area.min()[Geom::X];
- old_zoom->x1 = area.max()[Geom::X];
- old_zoom->y0 = area.min()[Geom::Y];
- old_zoom->y1 = area.max()[Geom::Y];
- if ( *history == NULL
- || !( ( ((NRRect *) ((*history)->data))->x0 == old_zoom->x0 ) &&
- ( ((NRRect *) ((*history)->data))->x1 == old_zoom->x1 ) &&
- ( ((NRRect *) ((*history)->data))->y0 == old_zoom->y0 ) &&
- ( ((NRRect *) ((*history)->data))->y1 == old_zoom->y1 ) ) )
- {
- *history = g_list_prepend (*history, old_zoom);
- } else {
- g_free(old_zoom);
- old_zoom = 0;
+ if (history.empty() || history.front() == area) {
+ history.push_front(area);
}
}
@@ -804,10 +786,9 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double
// save the zoom
if (log) {
- push_current_zoom(&zooms_past);
+ push_current_zoom(zooms_past);
// if we do a logged zoom, our zoom-forward list is invalidated, so delete it
- g_list_free (zooms_future);
- zooms_future = NULL;
+ zooms_future.clear();
}
double const cx = 0.5 * (x0 + x1);
@@ -871,6 +852,7 @@ Geom::Rect SPDesktop::get_display_area() const
double const scale = _d2w[0];
+ /// @fixme hardcoded desktop transform
return Geom::Rect(Geom::Point(viewbox.min()[Geom::X] / scale, viewbox.max()[Geom::Y] / -scale),
Geom::Point(viewbox.max()[Geom::X] / scale, viewbox.min()[Geom::Y] / -scale));
}
@@ -881,23 +863,20 @@ Geom::Rect SPDesktop::get_display_area() const
void
SPDesktop::prev_zoom()
{
- if (zooms_past == NULL) {
+ if (zooms_past.empty()) {
messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No previous zoom."));
return;
}
// push current zoom into forward zooms list
- push_current_zoom (&zooms_future);
+ push_current_zoom (zooms_future);
// restore previous zoom
- set_display_area (((NRRect *) zooms_past->data)->x0,
- ((NRRect *) zooms_past->data)->y0,
- ((NRRect *) zooms_past->data)->x1,
- ((NRRect *) zooms_past->data)->y1,
- 0, false);
+ Geom::Rect past = zooms_past.front();
+ set_display_area (past.left(), past.top(), past.right(), past.bottom(), 0, false);
// remove the just-added zoom from the past zooms list
- zooms_past = g_list_remove (zooms_past, ((NRRect *) zooms_past->data));
+ zooms_past.pop_front();
}
/**
@@ -906,23 +885,20 @@ SPDesktop::prev_zoom()
void
SPDesktop::next_zoom()
{
- if (zooms_future == NULL) {
+ if (zooms_future.empty()) {
this->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No next zoom."));
return;
}
// push current zoom into past zooms list
- push_current_zoom (&zooms_past);
+ push_current_zoom (zooms_past);
// restore next zoom
- set_display_area (((NRRect *) zooms_future->data)->x0,
- ((NRRect *) zooms_future->data)->y0,
- ((NRRect *) zooms_future->data)->x1,
- ((NRRect *) zooms_future->data)->y1,
- 0, false);
+ Geom::Rect future = zooms_future.front();
+ set_display_area (future.left(), future.top(), future.right(), future.bottom(), 0, false);
// remove the just-used zoom from the zooms_future list
- zooms_future = g_list_remove (zooms_future, ((NRRect *) zooms_future->data));
+ zooms_future.pop_front();
}
/** \brief Performs a quick zoom into what the user is working on
@@ -957,7 +933,7 @@ SPDesktop::zoom_quick (bool enable)
}
if (!zoomed) {
- Geom::OptRect const d = selection->bounds();
+ Geom::OptRect const d = selection->visualBounds();
if (d && d->area() * 2.0 < _quick_zoom_stored_area.area()) {
set_display_area(*d, true);
zoomed = true;
@@ -1109,7 +1085,7 @@ SPDesktop::zoom_page_width()
void
SPDesktop::zoom_selection()
{
- Geom::OptRect const d = selection->bounds();
+ Geom::OptRect const d = selection->visualBounds();
if ( !d || d->minExtent() < 0.1 ) {
return;
@@ -1137,7 +1113,7 @@ SPDesktop::zoom_drawing()
SPItem *docitem = doc()->getRoot();
g_return_if_fail (docitem != NULL);
- Geom::OptRect d = docitem->getBboxDesktop();
+ Geom::OptRect d = docitem->desktopVisualBounds();
/* Note that the second condition here indicates that
** there are no items in the drawing.
diff --git a/src/desktop.h b/src/desktop.h
index 5dcd014ca..d15fb7d69 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -117,8 +117,9 @@ public:
SPCSSAttr *current; ///< current style
bool _focusMode; ///< Whether we're focused working or general working
- GList *zooms_past;
- GList *zooms_future;
+ std::list<Geom::Rect> zooms_past;
+ std::list<Geom::Rect> zooms_future;
+
bool _quick_zoom_enabled; ///< Signifies that currently we're in quick zoom mode
Geom::Rect _quick_zoom_stored_area; ///< The area of the screen before quick zoom
unsigned int dkey;
@@ -359,7 +360,7 @@ private:
bool grids_visible; /* don't set this variable directly, use the method below */
void set_grids_visible(bool visible);
- void push_current_zoom (GList**);
+ void push_current_zoom(std::list<Geom::Rect> &);
sigc::signal<void,SPDesktop*,SPDocument*> _document_replaced_signal;
sigc::signal<void> _activate_signal;
diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp
index 109b235d0..a92b6392e 100644
--- a/src/dialogs/clonetiler.cpp
+++ b/src/dialogs/clonetiler.cpp
@@ -1170,10 +1170,9 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *)
y0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-y0", 0);
} else {
bool prefs_bbox = prefs->getBool("/tools/bounding_box", false);
- SPItem::BBoxType bbox_type = ( prefs_bbox ?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX );
- Geom::OptRect r = item->getBounds(item->i2doc_affine(),
- bbox_type);
+ SPItem::BBoxType bbox_type = ( !prefs_bbox ?
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX );
+ Geom::OptRect r = item->documentBounds(bbox_type);
if (r) {
w = r->dimensions()[Geom::X];
h = r->dimensions()[Geom::Y];
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index 0c2bc5adc..a19f9b60f 100644
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
@@ -783,20 +783,22 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/,
if ( SP_ACTIVE_DESKTOP ) {
SPDocument *doc;
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
- Geom::OptRect bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX);
+ Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds();
if (bbox) {
- sp_export_set_area (base, bbox->min()[Geom::X],
- bbox->min()[Geom::Y],
- bbox->max()[Geom::X],
- bbox->max()[Geom::Y]);
+ sp_export_set_area (base, bbox->left(),
+ bbox->top(),
+ bbox->right(),
+ bbox->bottom());
}
}
break;
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
- NRRect bbox;
- (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(&bbox, SPItem::RENDERING_BBOX);
- sp_export_set_area (base, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
+ Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->visualBounds();
+ sp_export_set_area (base, bbox->left(),
+ bbox->top(),
+ bbox->right(),
+ bbox->bottom());
}
break;
default:
@@ -852,7 +854,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false)
{
- bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->bounds(SPItem::RENDERING_BBOX);
+ bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->visualBounds();
/* Only if there is a selection that we can set
do we break, otherwise we fall through to the
drawing */
@@ -864,7 +866,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
/** \todo
* This returns wrong values if the document has a viewBox.
*/
- bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX);
+ bbox = doc->getRoot()->desktopVisualBounds();
/* If the drawing is valid, then we'll use it and break
otherwise we drop through to the page settings */
if (bbox) {
@@ -1129,8 +1131,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
dpi = DPI_BASE;
}
- Geom::OptRect area;
- item->invoke_bbox( area, item->i2dt_affine(), TRUE );
+ Geom::OptRect area = item->desktopVisualBounds();
if (area) {
gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5);
gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5);
@@ -1493,7 +1494,7 @@ sp_export_detect_size(GtkObject * base) {
switch (this_test[i]) {
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
- Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(SPItem::RENDERING_BBOX);
+ Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(SPItem::VISUAL_BBOX);
//std::cout << "Selection " << bbox;
if ( bbox && sp_export_bbox_equal(*bbox,current_bbox)) {
@@ -1504,7 +1505,7 @@ sp_export_detect_size(GtkObject * base) {
case SELECTION_DRAWING: {
SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
- Geom::OptRect bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX);
+ Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds();
// std::cout << "Drawing " << bbox2;
if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) {
diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp
index d0de6ad20..bd8381d8c 100644
--- a/src/dialogs/spellcheck.cpp
+++ b/src/dialogs/spellcheck.cpp
@@ -243,8 +243,8 @@ gint compare_text_bboxes (gconstpointer a, gconstpointer b)
SPItem *i1 = SP_ITEM(a);
SPItem *i2 = SP_ITEM(b);
- Geom::OptRect bbox1 = i1->getBounds(i1->i2dt_affine());
- Geom::OptRect bbox2 = i2->getBounds(i2->i2dt_affine());
+ Geom::OptRect bbox1 = i1->desktopVisualBounds();
+ Geom::OptRect bbox2 = i2->desktopVisualBounds();
if (!bbox1 || !bbox2) {
return 0;
}
diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp
index 4688a58e3..34b0d7cab 100644
--- a/src/display/canvas-arena.cpp
+++ b/src/display/canvas-arena.cpp
@@ -376,16 +376,14 @@ sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky)
}
void
-sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRRectL const &r)
+sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, Geom::IntRect const &r)
{
g_return_if_fail (ca != NULL);
g_return_if_fail (SP_IS_CANVAS_ARENA (ca));
- Geom::OptIntRect area = r.upgrade_2geom();
- if (!area) return;
- Inkscape::DrawingContext ct(surface, area->min());
+ Inkscape::DrawingContext ct(surface, r.min());
ca->drawing.update(Geom::IntRect::infinite(), ca->ctx);
- ca->drawing.render(ct, *area);
+ ca->drawing.render(ct, r);
}
/*
diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h
index f145a9c70..daab19d8e 100644
--- a/src/display/canvas-arena.h
+++ b/src/display/canvas-arena.h
@@ -61,7 +61,7 @@ GType sp_canvas_arena_get_type (void);
void sp_canvas_arena_set_pick_delta (SPCanvasArena *ca, gdouble delta);
void sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky);
-void sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRRectL const &area);
+void sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, Geom::IntRect const &area);
G_END_DECLS
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index 3ed1fa5a9..9ea06ec2d 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -99,7 +99,7 @@ sp_caxonomgrid_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, g
static void
sp_grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba)
{
- if ((x < buf->rect.x0) || (x >= buf->rect.x1))
+ if ((x < buf->rect.left()) || (x >= buf->rect.right()))
return;
cairo_move_to(buf->ct, 0.5 + x, 0.5 + ys);
@@ -526,21 +526,21 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
cairo_save(buf->ct);
- cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0);
+ cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top());
cairo_set_line_width(buf->ct, 1.0);
cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE);
// gc = gridcoordinates (the coordinates calculated from the grids origin 'grid->ow'.
- // sc = screencoordinates ( for example "buf->rect.x0" is in screencoordinates )
+ // sc = screencoordinates ( for example "buf->rect.left()" is in screencoordinates )
// bc = buffer patch coordinates
// tl = topleft ; br = bottomright
Geom::Point buf_tl_gc;
Geom::Point buf_br_gc;
- buf_tl_gc[Geom::X] = buf->rect.x0 - ow[Geom::X];
- buf_tl_gc[Geom::Y] = buf->rect.y0 - ow[Geom::Y];
- buf_br_gc[Geom::X] = buf->rect.x1 - ow[Geom::X];
- buf_br_gc[Geom::Y] = buf->rect.y1 - ow[Geom::Y];
+ buf_tl_gc[Geom::X] = buf->rect.left() - ow[Geom::X];
+ buf_tl_gc[Geom::Y] = buf->rect.top() - ow[Geom::Y];
+ buf_br_gc[Geom::X] = buf->rect.right() - ow[Geom::X];
+ buf_br_gc[Geom::Y] = buf->rect.bottom() - ow[Geom::Y];
gdouble x;
gdouble y;
@@ -549,15 +549,15 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
// x-axis always goes from topleft to bottomright. (0,0) - (1,1)
gdouble const xintercept_y_bc = (buf_tl_gc[Geom::X] * tan_angle[X]) - buf_tl_gc[Geom::Y] ;
- gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.y0;
- gint const xlinestart = round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[Geom::Y]) / lyw );
+ gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.top();
+ gint const xlinestart = round( (xstart_y_sc - buf->rect.left()*tan_angle[X] -ow[Geom::Y]) / lyw );
gint xlinenum = xlinestart;
// lines starting on left side.
- for (y = xstart_y_sc; y < buf->rect.y1; y += lyw, xlinenum++) {
- gint const x0 = buf->rect.x0;
+ for (y = xstart_y_sc; y < buf->rect.bottom(); y += lyw, xlinenum++) {
+ gint const x0 = buf->rect.left();
gint const y0 = round(y);
- gint const x1 = x0 + round( (buf->rect.y1 - y) / tan_angle[X] );
- gint const y1 = buf->rect.y1;
+ gint const x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] );
+ gint const y1 = buf->rect.bottom();
if (!scaled && (xlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -566,11 +566,11 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
}
// lines starting from top side
- gdouble const xstart_x_sc = buf->rect.x0 + (lxw_x - (xstart_y_sc - buf->rect.y0) / tan_angle[X]) ;
+ gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ;
xlinenum = xlinestart-1;
- for (x = xstart_x_sc; x < buf->rect.x1; x += lxw_x, xlinenum--) {
- gint const y0 = buf->rect.y0;
- gint const y1 = buf->rect.y1;
+ for (x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) {
+ gint const y0 = buf->rect.top();
+ gint const y1 = buf->rect.bottom();
gint const x0 = round(x);
gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] );
@@ -585,27 +585,27 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
gdouble const ystart_x_sc = floor (buf_tl_gc[Geom::X] / spacing_ylines) * spacing_ylines + ow[Geom::X];
gint const ylinestart = round((ystart_x_sc - ow[Geom::X]) / spacing_ylines);
gint ylinenum = ylinestart;
- for (x = ystart_x_sc; x < buf->rect.x1; x += spacing_ylines, ylinenum++) {
+ for (x = ystart_x_sc; x < buf->rect.right(); x += spacing_ylines, ylinenum++) {
gint const x0 = round(x);
if (!scaled && (ylinenum % empspacing) != 0) {
- sp_grid_vline (buf, x0, buf->rect.y0, buf->rect.y1 - 1, color);
+ sp_grid_vline (buf, x0, buf->rect.top(), buf->rect.bottom() - 1, color);
} else {
- sp_grid_vline (buf, x0, buf->rect.y0, buf->rect.y1 - 1, _empcolor);
+ sp_grid_vline (buf, x0, buf->rect.top(), buf->rect.bottom() - 1, _empcolor);
}
}
// z-axis always goes from bottomleft to topright. (0,1) - (1,0)
gdouble const zintercept_y_bc = (buf_tl_gc[Geom::X] * -tan_angle[Z]) - buf_tl_gc[Geom::Y] ;
- gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.y0;
- gint const zlinestart = round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[Geom::Y]) / lyw );
+ gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.top();
+ gint const zlinestart = round( (zstart_y_sc + buf->rect.left()*tan_angle[Z] - ow[Geom::Y]) / lyw );
gint zlinenum = zlinestart;
// lines starting from left side
- for (y = zstart_y_sc; y < buf->rect.y1; y += lyw, zlinenum++) {
- gint const x0 = buf->rect.x0;
+ for (y = zstart_y_sc; y < buf->rect.bottom(); y += lyw, zlinenum++) {
+ gint const x0 = buf->rect.left();
gint const y0 = round(y);
- gint const x1 = x0 + round( (y - buf->rect.y0 ) / tan_angle[Z] );
- gint const y1 = buf->rect.y0;
+ gint const x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] );
+ gint const y1 = buf->rect.top();
if (!scaled && (zlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -614,12 +614,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
}
// draw lines from bottom-up
- gdouble const zstart_x_sc = buf->rect.x0 + (y - buf->rect.y1) / tan_angle[Z] ;
- for (x = zstart_x_sc; x < buf->rect.x1; x += lxw_z, zlinenum++) {
- gint const y0 = buf->rect.y1;
- gint const y1 = buf->rect.y0;
+ gdouble const zstart_x_sc = buf->rect.left() + (y - buf->rect.bottom()) / tan_angle[Z] ;
+ for (x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) {
+ gint const y0 = buf->rect.bottom();
+ gint const y1 = buf->rect.top();
gint const x0 = round(x);
- gint const x1 = x0 + round( (buf->rect.y1 - buf->rect.y0) / tan_angle[Z] );
+ gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] );
if (!scaled && (zlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -744,13 +744,13 @@ CanvasAxonomGridSnapper::_getSnapLines(Geom::Point const &p) const
if (use_left_half) {
s.push_back(std::make_pair(norm_z, Geom::Point(grid->origin[Geom::X], y_proj_along_z_max)));
s.push_back(std::make_pair(norm_x, Geom::Point(grid->origin[Geom::X], y_proj_along_x_min)));
- s.push_back(std::make_pair(component_vectors[Geom::X], Geom::Point(x_max, 0)));
+ s.push_back(std::make_pair(Geom::Point(1, 0), Geom::Point(x_max, 0)));
}
if (use_right_half) {
s.push_back(std::make_pair(norm_z, Geom::Point(grid->origin[Geom::X], y_proj_along_z_min)));
s.push_back(std::make_pair(norm_x, Geom::Point(grid->origin[Geom::X], y_proj_along_x_max)));
- s.push_back(std::make_pair(component_vectors[Geom::X], Geom::Point(x_min, 0)));
+ s.push_back(std::make_pair(Geom::Point(1, 0), Geom::Point(x_min, 0)));
}
return s;
diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp
index 306b523ca..e015655a6 100644
--- a/src/display/canvas-bpath.cpp
+++ b/src/display/canvas-bpath.cpp
@@ -26,8 +26,6 @@
#include "display/cairo-utils.h"
#include "helper/geom.h"
-void nr_pixblock_render_bpath_rgba (Shape* theS,uint32_t color,NRRectL &area,char* destBuf,int stride);
-
static void sp_canvas_bpath_class_init (SPCanvasBPathClass *klass);
static void sp_canvas_bpath_init (SPCanvasBPath *path);
static void sp_canvas_bpath_destroy (GtkObject *object);
@@ -139,7 +137,7 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf)
{
SPCanvasBPath *cbp = SP_CANVAS_BPATH (item);
- Geom::Rect area (Geom::Point(buf->rect.x0, buf->rect.y0), Geom::Point(buf->rect.x1, buf->rect.y1));
+ Geom::Rect area = buf->rect;
if ( !cbp->curve ||
((cbp->stroke_rgba & 0xff) == 0 && (cbp->fill_rgba & 0xff) == 0 ) ||
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index b3ec73e78..bdf0d6fb0 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -834,94 +834,45 @@ CanvasXYGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/)
static void
grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba)
{
- if ((y < buf->rect.y0) || (y >= buf->rect.y1))
+ if ((y < buf->rect.top()) || (y >= buf->rect.bottom()))
return;
cairo_move_to(buf->ct, 0.5 + xs, 0.5 + y);
cairo_line_to(buf->ct, 0.5 + xe, 0.5 + y);
ink_cairo_set_source_rgba32(buf->ct, rgba);
cairo_stroke(buf->ct);
-#if 0
- guint r, g, b, a;
- gint x0, x1, x;
- guchar *p;
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
- x0 = MAX (buf->rect.x0, xs);
- x1 = MIN (buf->rect.x1, xe + 1);
- p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4;
- for (x = x0; x < x1; x++) {
- p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
- p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
- p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
- p += 4;
- }
-#endif
}
static void
grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba)
{
- if ((x < buf->rect.x0) || (x >= buf->rect.x1))
+ if ((x < buf->rect.left()) || (x >= buf->rect.right()))
return;
cairo_move_to(buf->ct, 0.5 + x, 0.5 + ys);
cairo_line_to(buf->ct, 0.5 + x, 0.5 + ye);
ink_cairo_set_source_rgba32(buf->ct, rgba);
cairo_stroke(buf->ct);
- #if 0
- guint r, g, b, a;
- gint y0, y1, y;
- guchar *p;
- r = NR_RGBA32_R(rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
- y0 = MAX (buf->rect.y0, ys);
- y1 = MIN (buf->rect.y1, ye + 1);
- p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4;
- for (y = y0; y < y1; y++) {
- p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
- p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
- p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
- p += buf->buf_rowstride;
- }
- #endif
}
static void
grid_dot (SPCanvasBuf *buf, gint x, gint y, guint32 rgba)
{
- if ( (y < buf->rect.y0) || (y >= buf->rect.y1)
- || (x < buf->rect.x0) || (x >= buf->rect.x1) )
+ if ( (y < buf->rect.top()) || (y >= buf->rect.bottom())
+ || (x < buf->rect.left()) || (x >= buf->rect.right()) )
return;
cairo_rectangle(buf->ct, x, y, 1, 1);
ink_cairo_set_source_rgba32(buf->ct, rgba);
cairo_fill(buf->ct);
-
-#if 0
- guint r, g, b, a;
- guchar *p;
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
- p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4;
- p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
- p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
- p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
-#endif
}
void
CanvasXYGrid::Render (SPCanvasBuf *buf)
{
- gdouble const sxg = floor ((buf->rect.x0 - ow[Geom::X]) / sw[Geom::X]) * sw[Geom::X] + ow[Geom::X];
+ gdouble const sxg = floor ((buf->rect.left() - ow[Geom::X]) / sw[Geom::X]) * sw[Geom::X] + ow[Geom::X];
gint const xlinestart = round((sxg - ow[Geom::X]) / sw[Geom::X]);
- gdouble const syg = floor ((buf->rect.y0 - ow[Geom::Y]) / sw[Geom::Y]) * sw[Geom::Y] + ow[Geom::Y];
+ gdouble const syg = floor ((buf->rect.top() - ow[Geom::Y]) / sw[Geom::Y]) * sw[Geom::Y] + ow[Geom::Y];
gint const ylinestart = round((syg - ow[Geom::Y]) / sw[Geom::Y]);
//set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
@@ -935,41 +886,41 @@ CanvasXYGrid::Render (SPCanvasBuf *buf)
}
cairo_save(buf->ct);
- cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0);
+ cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top());
cairo_set_line_width(buf->ct, 1.0);
cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE);
if (!render_dotted) {
gint ylinenum;
gdouble y;
- for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) {
+ for (y = syg, ylinenum = ylinestart; y < buf->rect.bottom(); y += sw[Geom::Y], ylinenum++) {
gint const y0 = round(y);
if (!scaled[Geom::Y] && (ylinenum % empspacing) != 0) {
- grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, color);
+ grid_hline (buf, y0, buf->rect.left(), buf->rect.right() - 1, color);
} else {
- grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, _empcolor);
+ grid_hline (buf, y0, buf->rect.left(), buf->rect.right() - 1, _empcolor);
}
}
gint xlinenum;
gdouble x;
- for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) {
+ for (x = sxg, xlinenum = xlinestart; x < buf->rect.right(); x += sw[Geom::X], xlinenum++) {
gint const ix = round(x);
if (!scaled[Geom::X] && (xlinenum % empspacing) != 0) {
- grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, color);
+ grid_vline (buf, ix, buf->rect.top(), buf->rect.bottom(), color);
} else {
- grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, _empcolor);
+ grid_vline (buf, ix, buf->rect.top(), buf->rect.bottom(), _empcolor);
}
}
} else {
gint ylinenum;
gdouble y;
- for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) {
+ for (y = syg, ylinenum = ylinestart; y < buf->rect.bottom(); y += sw[Geom::Y], ylinenum++) {
gint const iy = round(y);
gint xlinenum;
gdouble x;
- for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) {
+ for (x = sxg, xlinenum = xlinestart; x < buf->rect.right(); x += sw[Geom::X], xlinenum++) {
gint const ix = round(x);
if ( (!scaled[Geom::X] && (xlinenum % empspacing) != 0)
|| (!scaled[Geom::Y] && (ylinenum % empspacing) != 0)
@@ -1042,14 +993,16 @@ CanvasXYGridSnapper::_getSnapLines(Geom::Point const &p) const
Geom::Coord rounded;
Geom::Point point_on_line;
+ Geom::Point cvec(0.,0.);
+ cvec[i] = 1.;
rounded = Inkscape::Util::round_to_upper_multiple_plus(p[i], spacing, grid->origin[i]);
point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0);
- s.push_back(std::make_pair(component_vectors[i], point_on_line));
+ s.push_back(std::make_pair(cvec, point_on_line));
rounded = Inkscape::Util::round_to_lower_multiple_plus(p[i], spacing, grid->origin[i]);
point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0);
- s.push_back(std::make_pair(component_vectors[i], point_on_line));
+ s.push_back(std::make_pair(cvec, point_on_line));
}
return s;
diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp
index 683e2f93c..185d10b15 100644
--- a/src/display/canvas-text.cpp
+++ b/src/display/canvas-text.cpp
@@ -116,8 +116,8 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf)
return;
Geom::Point s = cl->s * cl->affine;
- double offsetx = s[Geom::X] - buf->rect.x0;
- double offsety = s[Geom::Y] - buf->rect.y0;
+ double offsetx = s[Geom::X] - buf->rect.left();
+ double offsety = s[Geom::Y] - buf->rect.top();
offsetx -= anchor_offset_x;
offsety -= anchor_offset_y;
diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp
index a678c3feb..998c4b6e4 100644
--- a/src/display/drawing-group.cpp
+++ b/src/display/drawing-group.cpp
@@ -14,7 +14,6 @@
#include "display/drawing-context.h"
#include "display/drawing-item.h"
#include "display/drawing-group.h"
-#include "libnr/nr-values.h"
#include "style.h"
namespace Inkscape {
@@ -58,7 +57,7 @@ DrawingGroup::setChildTransform(Geom::Affine const &new_trans)
current = *_child_transform;
}
- if (!Geom::are_near(current, new_trans, NR_EPSILON)) {
+ if (!Geom::are_near(current, new_trans, 1e-18)) {
// mark the area where the object was for redraw.
_markForRendering();
if (new_trans.isIdentity()) {
diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp
index a5496e999..3fe56b6de 100644
--- a/src/display/drawing-item.cpp
+++ b/src/display/drawing-item.cpp
@@ -176,7 +176,7 @@ DrawingItem::setTransform(Geom::Affine const &new_trans)
current = *_transform;
}
- if (!Geom::are_near(current, new_trans, NR_EPSILON)) {
+ if (!Geom::are_near(current, new_trans, 1e-18)) {
// mark the area where the object was for redraw.
_markForRendering();
if (new_trans.isIdentity()) {
@@ -456,7 +456,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag
// If we are invisible, return immediately
if (!_visible) return RENDER_OK;
- if (_ctm.isSingular(NR_EPSILON)) return RENDER_OK;
+ if (_ctm.isSingular(1e-18)) return RENDER_OK;
// TODO convert outline rendering to a separate virtual function
if (outline) {
diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp
index ac0ff2ccb..6e28c0184 100644
--- a/src/display/drawing-shape.cpp
+++ b/src/display/drawing-shape.cpp
@@ -25,7 +25,6 @@
#include "display/drawing-shape.h"
#include "helper/geom-curves.h"
#include "helper/geom.h"
-#include "libnr/nr-convert2geom.h"
#include "preferences.h"
#include "style.h"
#include "svg/svg.h"
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp
index 0d2905d23..f2802c6fe 100644
--- a/src/display/guideline.cpp
+++ b/src/display/guideline.cpp
@@ -111,7 +111,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf)
SPGuideLine const *gl = SP_GUIDELINE (item);
cairo_save(buf->ct);
- cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0);
+ cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top());
ink_cairo_set_source_rgba32(buf->ct, gl->rgba);
cairo_set_line_width(buf->ct, 1);
cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE);
@@ -134,49 +134,49 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf)
if ( Geom::are_near(normal_dt[Geom::Y], 0.) ) { // is vertical?
int position = round(point_on_line_dt[Geom::X]);
- cairo_move_to(buf->ct, position + 0.5, buf->rect.y0 + 0.5);
- cairo_line_to(buf->ct, position + 0.5, buf->rect.y1 - 0.5);
+ cairo_move_to(buf->ct, position + 0.5, buf->rect.top() + 0.5);
+ cairo_line_to(buf->ct, position + 0.5, buf->rect.bottom() - 0.5);
cairo_stroke(buf->ct);
} else if ( Geom::are_near(normal_dt[Geom::X], 0.) ) { // is horizontal?
int position = round(point_on_line_dt[Geom::Y]);
- cairo_move_to(buf->ct, buf->rect.x0 + 0.5, position + 0.5);
- cairo_line_to(buf->ct, buf->rect.x1 - 0.5, position + 0.5);
+ cairo_move_to(buf->ct, buf->rect.left() + 0.5, position + 0.5);
+ cairo_line_to(buf->ct, buf->rect.right() - 0.5, position + 0.5);
cairo_stroke(buf->ct);
} else {
// render angled line. Once intersection has been detected, draw from there.
Geom::Point parallel_to_line( normal_dt.ccw() );
//try to intersect with left vertical of rect
- double y_intersect_left = (buf->rect.x0 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y];
- if ( (y_intersect_left >= buf->rect.y0) && (y_intersect_left <= buf->rect.y1) ) {
+ double y_intersect_left = (buf->rect.left() - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y];
+ if ( (y_intersect_left >= buf->rect.top()) && (y_intersect_left <= buf->rect.bottom()) ) {
// intersects with left vertical!
- double y_intersect_right = (buf->rect.x1 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y];
- sp_guideline_drawline (buf, buf->rect.x0, static_cast<gint>(round(y_intersect_left)), buf->rect.x1, static_cast<gint>(round(y_intersect_right)), gl->rgba);
+ double y_intersect_right = (buf->rect.right() - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y];
+ sp_guideline_drawline (buf, buf->rect.left(), static_cast<gint>(round(y_intersect_left)), buf->rect.right(), static_cast<gint>(round(y_intersect_right)), gl->rgba);
goto end;
}
//try to intersect with right vertical of rect
- double y_intersect_right = (buf->rect.x1 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y];
- if ( (y_intersect_right >= buf->rect.y0) && (y_intersect_right <= buf->rect.y1) ) {
+ double y_intersect_right = (buf->rect.right() - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y];
+ if ( (y_intersect_right >= buf->rect.top()) && (y_intersect_right <= buf->rect.bottom()) ) {
// intersects with right vertical!
- sp_guideline_drawline (buf, buf->rect.x1, static_cast<gint>(round(y_intersect_right)), buf->rect.x0, static_cast<gint>(round(y_intersect_left)), gl->rgba);
+ sp_guideline_drawline (buf, buf->rect.right(), static_cast<gint>(round(y_intersect_right)), buf->rect.left(), static_cast<gint>(round(y_intersect_left)), gl->rgba);
goto end;
}
//try to intersect with top horizontal of rect
- double x_intersect_top = (buf->rect.y0 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X];
- if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) {
+ double x_intersect_top = (buf->rect.top() - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X];
+ if ( (x_intersect_top >= buf->rect.left()) && (x_intersect_top <= buf->rect.right()) ) {
// intersects with top horizontal!
- double x_intersect_bottom = (buf->rect.y1 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X];
- sp_guideline_drawline (buf, static_cast<gint>(round(x_intersect_top)), buf->rect.y0, static_cast<gint>(round(x_intersect_bottom)), buf->rect.y1, gl->rgba);
+ double x_intersect_bottom = (buf->rect.bottom() - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X];
+ sp_guideline_drawline (buf, static_cast<gint>(round(x_intersect_top)), buf->rect.top(), static_cast<gint>(round(x_intersect_bottom)), buf->rect.bottom(), gl->rgba);
goto end;
}
//try to intersect with bottom horizontal of rect
- double x_intersect_bottom = (buf->rect.y1 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X];
- if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) {
+ double x_intersect_bottom = (buf->rect.bottom() - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X];
+ if ( (x_intersect_top >= buf->rect.left()) && (x_intersect_top <= buf->rect.right()) ) {
// intersects with bottom horizontal!
- sp_guideline_drawline (buf, static_cast<gint>(round(x_intersect_bottom)), buf->rect.y1, static_cast<gint>(round(x_intersect_top)), buf->rect.y0, gl->rgba);
+ sp_guideline_drawline (buf, static_cast<gint>(round(x_intersect_bottom)), buf->rect.bottom(), static_cast<gint>(round(x_intersect_top)), buf->rect.top(), gl->rgba);
goto end;
}
}
diff --git a/src/display/nr-3dutils.h b/src/display/nr-3dutils.h
index 44cb371e6..c278c81c6 100644
--- a/src/display/nr-3dutils.h
+++ b/src/display/nr-3dutils.h
@@ -17,8 +17,6 @@
#include <gdk/gdk.h>
#include <2geom/forward.h>
-struct NRPixBlock;
-
namespace NR {
#define X_3D 0
diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp
index 6fa34bf0b..33718ed68 100644
--- a/src/display/nr-filter-colormatrix.cpp
+++ b/src/display/nr-filter-colormatrix.cpp
@@ -188,10 +188,6 @@ bool FilterColorMatrix::can_handle_affine(Geom::Affine const &)
return true;
}
-void FilterColorMatrix::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/)
-{
-}
-
double FilterColorMatrix::complexity(Geom::Affine const &)
{
return 2.0;
diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h
index 5864a010e..5f21a4210 100644
--- a/src/display/nr-filter-colormatrix.h
+++ b/src/display/nr-filter-colormatrix.h
@@ -37,7 +37,6 @@ public:
virtual void render_cairo(FilterSlot &slot);
virtual bool can_handle_affine(Geom::Affine const &);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
virtual void set_type(FilterColorMatrixType type);
diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp
index 887352f62..226a73cef 100644
--- a/src/display/nr-filter-component-transfer.cpp
+++ b/src/display/nr-filter-component-transfer.cpp
@@ -304,10 +304,6 @@ bool FilterComponentTransfer::can_handle_affine(Geom::Affine const &)
return true;
}
-void FilterComponentTransfer::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/)
-{
-}
-
double FilterComponentTransfer::complexity(Geom::Affine const &)
{
return 2.0;
diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h
index 6d65ae6d1..558d097a8 100644
--- a/src/display/nr-filter-component-transfer.h
+++ b/src/display/nr-filter-component-transfer.h
@@ -37,7 +37,6 @@ public:
virtual void render_cairo(FilterSlot &slot);
virtual bool can_handle_affine(Geom::Affine const &);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
FilterComponentTransferType type[4];
diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp
index 469baf346..5469aff88 100644
--- a/src/display/nr-filter-convolve-matrix.cpp
+++ b/src/display/nr-filter-convolve-matrix.cpp
@@ -202,14 +202,15 @@ void FilterConvolveMatrix::set_preserveAlpha(bool pa){
preserveAlpha = pa;
}
-void FilterConvolveMatrix::area_enlarge(NRRectL &area, Geom::Affine const &/*trans*/)
+void FilterConvolveMatrix::area_enlarge(Geom::IntRect &area, Geom::Affine const &/*trans*/)
{
//Seems to me that since this filter's operation is resolution dependent,
// some spurious pixels may still appear at the borders when low zooming or rotating. Needs a better fix.
- area.x0 -= targetX;
- area.y0 -= targetY;
- area.x1 += orderX - targetX - 1; // This makes sure the last row/column in the original image corresponds to the last row/column in the new image that can be convolved without adjusting the boundary conditions).
- area.y1 += orderY - targetY - 1;
+ area.setMin(area.min() - Geom::IntPoint(targetX, targetY));
+ // This makes sure the last row/column in the original image corresponds
+ // to the last row/column in the new image that can be convolved without
+ // adjusting the boundary conditions).
+ area.setMax(area.max() + Geom::IntPoint(orderX - targetX - 1, orderY - targetY -1));
}
double FilterConvolveMatrix::complexity(Geom::Affine const &)
diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h
index 8b7fc35d1..4041ff96f 100644
--- a/src/display/nr-filter-convolve-matrix.h
+++ b/src/display/nr-filter-convolve-matrix.h
@@ -13,7 +13,6 @@
*/
#include "display/nr-filter-primitive.h"
-#include "libnr/nr-rect-l.h"
#include <vector>
namespace Inkscape {
@@ -35,7 +34,7 @@ public:
virtual ~FilterConvolveMatrix();
virtual void render_cairo(FilterSlot &slot);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
+ virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
void set_targetY(int coord);
diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp
index 14144ace5..9df771879 100644
--- a/src/display/nr-filter-diffuselighting.cpp
+++ b/src/display/nr-filter-diffuselighting.cpp
@@ -21,7 +21,6 @@
#include "display/nr-filter-units.h"
#include "display/nr-filter-utils.h"
#include "display/nr-light.h"
-#include "libnr/nr-rect-l.h"
namespace Inkscape {
namespace Filters {
@@ -159,16 +158,13 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot)
cairo_surface_destroy(out);
}
-void FilterDiffuseLighting::area_enlarge(NRRectL &area, Geom::Affine const & /*trans*/)
+void FilterDiffuseLighting::area_enlarge(Geom::IntRect &area, Geom::Affine const & /*trans*/)
{
// TODO: support kernelUnitLength
// We expand the area by 1 in every direction to avoid artifacts on tile edges.
// However, it means that edge pixels will be incorrect.
- area.x0 -= 1;
- area.x1 += 1;
- area.y0 -= 1;
- area.y1 += 1;
+ area.expandBy(1);
}
double FilterDiffuseLighting::complexity(Geom::Affine const &)
diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h
index bb3ceccb3..0da6cc218 100644
--- a/src/display/nr-filter-diffuselighting.h
+++ b/src/display/nr-filter-diffuselighting.h
@@ -32,7 +32,7 @@ public:
static FilterPrimitive *create();
virtual ~FilterDiffuseLighting();
virtual void render_cairo(FilterSlot &slot);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
+ virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
union {
diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp
index 75e310339..01c644bc1 100644
--- a/src/display/nr-filter-displacement-map.cpp
+++ b/src/display/nr-filter-displacement-map.cpp
@@ -125,7 +125,7 @@ void FilterDisplacementMap::set_channel_selector(int s, FilterDisplacementMapCha
if (s == 1) Ychannel = ch;
}
-void FilterDisplacementMap::area_enlarge(NRRectL &area, Geom::Affine const &trans)
+void FilterDisplacementMap::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans)
{
//I assume scale is in user coordinates (?!?)
//FIXME: trans should be multiplied by some primitiveunits2user, shouldn't it?
@@ -134,10 +134,7 @@ void FilterDisplacementMap::area_enlarge(NRRectL &area, Geom::Affine const &tran
double scaley = scale/2.*(std::fabs(trans[2])+std::fabs(trans[3]));
//FIXME: no +2 should be there!... (noticable only for big scales at big zoom factor)
- area.x0 -= (int)(scalex)+2;
- area.x1 += (int)(scalex)+2;
- area.y0 -= (int)(scaley)+2;
- area.y1 += (int)(scaley)+2;
+ area.expandBy(scalex+2, scaley+2);
}
double FilterDisplacementMap::complexity(Geom::Affine const &)
diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h
index 393a904c1..a01930045 100644
--- a/src/display/nr-filter-displacement-map.h
+++ b/src/display/nr-filter-displacement-map.h
@@ -16,7 +16,6 @@
#include "display/nr-filter-primitive.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-units.h"
-#include "libnr/nr-rect-l.h"
namespace Inkscape {
namespace Filters {
@@ -28,7 +27,7 @@ public:
virtual ~FilterDisplacementMap();
virtual void render_cairo(FilterSlot &slot);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
+ virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
virtual void set_input(int slot);
diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp
index 5716c1bc5..7db14737b 100644
--- a/src/display/nr-filter-flood.cpp
+++ b/src/display/nr-filter-flood.cpp
@@ -81,11 +81,6 @@ void FilterFlood::set_opacity(double o) {
void FilterFlood::set_icc(SVGICCColor *icc_color) {
icc = icc_color;
}
-
-void FilterFlood::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/)
-{
-}
-
double FilterFlood::complexity(Geom::Affine const &)
{
// flood is actually less expensive than normal rendering,
diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h
index f744e9f48..8568502ff 100644
--- a/src/display/nr-filter-flood.h
+++ b/src/display/nr-filter-flood.h
@@ -27,7 +27,6 @@ public:
virtual void render_cairo(FilterSlot &slot);
virtual bool can_handle_affine(Geom::Affine const &);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
virtual bool uses_background() { return false; }
diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp
index 8a7244e02..7a65519e0 100644
--- a/src/display/nr-filter-gaussian.cpp
+++ b/src/display/nr-filter-gaussian.cpp
@@ -667,17 +667,14 @@ void FilterGaussian::render_cairo(FilterSlot &slot)
}
}
-void FilterGaussian::area_enlarge(NRRectL &area, Geom::Affine const &trans)
+void FilterGaussian::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans)
{
int area_x = _effect_area_scr(_deviation_x * trans.expansionX());
int area_y = _effect_area_scr(_deviation_y * trans.expansionY());
// maximum is used because rotations can mix up these directions
// TODO: calculate a more tight-fitting rendering area
int area_max = std::max(area_x, area_y);
- area.x0 -= area_max;
- area.x1 += area_max;
- area.y0 -= area_max;
- area.y1 += area_max;
+ area.expandBy(area_max);
}
bool FilterGaussian::can_handle_affine(Geom::Affine const &)
diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h
index f52bea01e..1c35a0f1d 100644
--- a/src/display/nr-filter-gaussian.h
+++ b/src/display/nr-filter-gaussian.h
@@ -35,7 +35,7 @@ public:
virtual ~FilterGaussian();
virtual void render_cairo(FilterSlot &slot);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &m);
+ virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &m);
virtual bool can_handle_affine(Geom::Affine const &m);
virtual double complexity(Geom::Affine const &ctm);
diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp
index a22d23548..8b2161425 100644
--- a/src/display/nr-filter-image.cpp
+++ b/src/display/nr-filter-image.cpp
@@ -19,7 +19,6 @@
#include "display/nr-filter.h"
#include "display/nr-filter-image.h"
#include "display/nr-filter-units.h"
-#include "libnr/nr-rect-l.h"
namespace Inkscape {
namespace Filters {
@@ -74,7 +73,7 @@ void FilterImage::render_cairo(FilterSlot &slot)
document->ensureUpToDate();
Drawing drawing;
- Geom::OptRect optarea = SVGElem->getBounds(Geom::identity());
+ Geom::OptRect optarea = SVGElem->visualBounds();
if (!optarea) return;
unsigned const key = SPItem::display_key_new(1);
diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp
index 9e43d01f3..b6aea1b06 100644
--- a/src/display/nr-filter-morphology.cpp
+++ b/src/display/nr-filter-morphology.cpp
@@ -147,15 +147,12 @@ void FilterMorphology::render_cairo(FilterSlot &slot)
cairo_surface_destroy(out);
}
-void FilterMorphology::area_enlarge(NRRectL &area, Geom::Affine const &trans)
+void FilterMorphology::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans)
{
int enlarge_x = ceil(xradius * trans.expansionX());
int enlarge_y = ceil(yradius * trans.expansionY());
- area.x0 -= enlarge_x;
- area.x1 += enlarge_x;
- area.y0 -= enlarge_y;
- area.y1 += enlarge_y;
+ area.expandBy(enlarge_x, enlarge_y);
}
double FilterMorphology::complexity(Geom::Affine const &trans)
diff --git a/src/display/nr-filter-morphology.h b/src/display/nr-filter-morphology.h
index 512eca83c..0574ff4ad 100644
--- a/src/display/nr-filter-morphology.h
+++ b/src/display/nr-filter-morphology.h
@@ -32,7 +32,7 @@ public:
virtual ~FilterMorphology();
virtual void render_cairo(FilterSlot &slot);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
+ virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
void set_operator(FilterMorphologyOperator &o);
diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp
index db8b6d92a..833f6ecc9 100644
--- a/src/display/nr-filter-offset.cpp
+++ b/src/display/nr-filter-offset.cpp
@@ -13,7 +13,6 @@
#include "display/nr-filter-offset.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-units.h"
-#include "libnr/nr-rect-l.h"
namespace Inkscape {
namespace Filters {
@@ -65,24 +64,30 @@ void FilterOffset::set_dy(double amount) {
dy = amount;
}
-void FilterOffset::area_enlarge(NRRectL &area, Geom::Affine const &trans)
+void FilterOffset::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans)
{
Geom::Point offset(dx, dy);
offset *= trans;
offset[X] -= trans[4];
offset[Y] -= trans[5];
+ double x0, y0, x1, y1;
+ x0 = area.left();
+ y0 = area.top();
+ x1 = area.right();
+ y1 = area.bottom();
if (offset[X] > 0) {
- area.x0 -= ceil(offset[X]);
+ x0 -= ceil(offset[X]);
} else {
- area.x1 -= floor(offset[X]);
+ x1 -= floor(offset[X]);
}
if (offset[Y] > 0) {
- area.y0 -= ceil(offset[Y]);
+ y0 -= ceil(offset[Y]);
} else {
- area.y1 -= floor(offset[Y]);
+ y1 -= floor(offset[Y]);
}
+ area = Geom::IntRect(x0, y0, x1, y1);
}
double FilterOffset::complexity(Geom::Affine const &)
diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h
index 841be6008..1ecc1621e 100644
--- a/src/display/nr-filter-offset.h
+++ b/src/display/nr-filter-offset.h
@@ -15,7 +15,6 @@
#include "display/nr-filter-primitive.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-units.h"
-#include "libnr/nr-rect-l.h"
namespace Inkscape {
namespace Filters {
@@ -27,7 +26,7 @@ public:
virtual ~FilterOffset();
virtual void render_cairo(FilterSlot &slot);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
+ virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans);
virtual bool can_handle_affine(Geom::Affine const &);
virtual double complexity(Geom::Affine const &ctm);
diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp
index 0a445b9e6..c6bd8a74e 100644
--- a/src/display/nr-filter-primitive.cpp
+++ b/src/display/nr-filter-primitive.cpp
@@ -53,7 +53,7 @@ void FilterPrimitive::render_cairo(FilterSlot &slot)
slot.set(_output, in);
}
-void FilterPrimitive::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*m*/)
+void FilterPrimitive::area_enlarge(Geom::IntRect &/*area*/, Geom::Affine const &/*m*/)
{
// This doesn't need to do anything by default
}
diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h
index 501d76447..42a1c98b7 100644
--- a/src/display/nr-filter-primitive.h
+++ b/src/display/nr-filter-primitive.h
@@ -12,11 +12,10 @@
#define SEEN_NR_FILTER_PRIMITIVE_H
#include <2geom/forward.h>
+#include <2geom/rect.h>
#include "display/nr-filter-types.h"
#include "svg/svg-length.h"
-struct NRRectL;
-
namespace Inkscape {
namespace Filters {
@@ -30,7 +29,7 @@ public:
virtual void render_cairo(FilterSlot &slot);
virtual int render(FilterSlot & /*slot*/, FilterUnits const & /*units*/) { return 0; }
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &m);
+ virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &m);
/**
* Sets the input slot number 'slot' to be used as input in rendering
diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h
index d41b5180b..805027bfe 100644
--- a/src/display/nr-filter-slot.h
+++ b/src/display/nr-filter-slot.h
@@ -67,7 +67,6 @@ public:
FilterUnits const &get_units() const { return _units; }
Geom::Rect get_slot_area() const;
- NRRectL get_sg_area() const { NRRectL ret(_source_graphic_area); return ret; }
private:
typedef std::map<int, cairo_surface_t *> SlotMap;
@@ -77,7 +76,6 @@ private:
//Geom::Rect _source_bbox; ///< bounding box of source graphic surface
//Geom::Rect _intermediate_bbox; ///< bounding box of intermediate surfaces
-// NRRectL _slot_area;
int _slot_w, _slot_h;
double _slot_x, _slot_y;
cairo_surface_t *_source_graphic;
diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp
index c28fd485a..0530e38cb 100644
--- a/src/display/nr-filter-specularlighting.cpp
+++ b/src/display/nr-filter-specularlighting.cpp
@@ -21,7 +21,6 @@
#include "display/nr-filter-units.h"
#include "display/nr-filter-utils.h"
#include "display/nr-light.h"
-#include "libnr/nr-rect-l.h"
namespace Inkscape {
namespace Filters {
@@ -174,14 +173,10 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot)
cairo_surface_destroy(out);
}
-void FilterSpecularLighting::area_enlarge(NRRectL &area, Geom::Affine const & /*trans*/)
+void FilterSpecularLighting::area_enlarge(Geom::IntRect &area, Geom::Affine const & /*trans*/)
{
// TODO: support kernelUnitLength
-
- area.x0 -= 1;
- area.x1 += 1;
- area.y0 -= 1;
- area.y1 += 1;
+ area.expandBy(1);
}
double FilterSpecularLighting::complexity(Geom::Affine const &)
diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h
index 8471b70b0..33ea17a87 100644
--- a/src/display/nr-filter-specularlighting.h
+++ b/src/display/nr-filter-specularlighting.h
@@ -33,7 +33,7 @@ public:
virtual ~FilterSpecularLighting();
virtual void render_cairo(FilterSlot &slot);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
+ virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
union {
diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp
index 4aadde2aa..93ca50210 100644
--- a/src/display/nr-filter-tile.cpp
+++ b/src/display/nr-filter-tile.cpp
@@ -9,6 +9,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <glib.h>
#include "display/nr-filter-tile.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-units.h"
@@ -41,10 +42,6 @@ void FilterTile::render_cairo(FilterSlot &slot)
slot.set(_output, in);
}
-void FilterTile::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/)
-{
-}
-
double FilterTile::complexity(Geom::Affine const &)
{
return 1.0;
diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h
index 37e257f79..dc5b99a42 100644
--- a/src/display/nr-filter-tile.h
+++ b/src/display/nr-filter-tile.h
@@ -26,7 +26,6 @@ public:
virtual ~FilterTile();
virtual void render_cairo(FilterSlot &slot);
- virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans);
virtual double complexity(Geom::Affine const &ctm);
};
diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp
index f065ded11..7e47c3bd9 100644
--- a/src/display/nr-filter-turbulence.cpp
+++ b/src/display/nr-filter-turbulence.cpp
@@ -23,7 +23,6 @@
#include "display/nr-filter-turbulence.h"
#include "display/nr-filter-units.h"
#include "display/nr-filter-utils.h"
-#include "libnr/nr-rect-l.h"
#include <math.h>
namespace Inkscape {
diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h
index 0b451d355..360853364 100644
--- a/src/display/nr-filter-turbulence.h
+++ b/src/display/nr-filter-turbulence.h
@@ -25,7 +25,6 @@
#include "display/nr-filter-primitive.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-units.h"
-#include "libnr/nr-rect-l.h"
namespace Inkscape {
namespace Filters {
diff --git a/src/display/nr-filter-units.cpp b/src/display/nr-filter-units.cpp
index baf4af45d..369deeb00 100644
--- a/src/display/nr-filter-units.cpp
+++ b/src/display/nr-filter-units.cpp
@@ -12,7 +12,6 @@
#include <glib.h>
#include "display/nr-filter-units.h"
-#include "libnr/nr-rect-l.h"
#include "sp-filter-units.h"
#include <2geom/transforms.h>
diff --git a/src/display/nr-filter-units.h b/src/display/nr-filter-units.h
index 1cb4fdbce..f918cf12e 100644
--- a/src/display/nr-filter-units.h
+++ b/src/display/nr-filter-units.h
@@ -13,7 +13,6 @@
*/
#include "sp-filter-units.h"
-#include "libnr/nr-rect-l.h"
#include <2geom/affine.h>
#include <2geom/rect.h>
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp
index 450ce689d..6e3eb91d5 100644
--- a/src/display/nr-filter.cpp
+++ b/src/display/nr-filter.cpp
@@ -177,11 +177,9 @@ void Filter::set_primitive_units(SPFilterUnits unit) {
}
void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item) const {
- NRRectL b(bbox);
for (unsigned i = 0 ; i < _primitive.size() ; i++) {
- if (_primitive[i]) _primitive[i]->area_enlarge(b, item->ctm());
+ if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm());
}
- bbox = *b.upgrade_2geom();
/*
TODO: something. See images at the bottom of filters.svg with medium-low
diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h
index 32e1df60b..d53005c5d 100644
--- a/src/display/nr-filter.h
+++ b/src/display/nr-filter.h
@@ -16,7 +16,6 @@
#include <cairo.h>
#include "display/nr-filter-primitive.h"
#include "display/nr-filter-types.h"
-#include "libnr/nr-rect.h"
#include "svg/svg-length.h"
#include "sp-filter-units.h"
#include "gc-managed.h"
diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp
index fa5dd0d98..6e8ccb030 100644
--- a/src/display/nr-style.cpp
+++ b/src/display/nr-style.cpp
@@ -14,7 +14,6 @@
#include "sp-paint-server.h"
#include "display/canvas-bpath.h" // contains SPStrokeJoinType, SPStrokeCapType etc. (WTF!)
#include "display/drawing-context.h"
-#include "libnr/nr-rect.h"
void NRStyle::Paint::clear()
{
@@ -150,8 +149,7 @@ bool NRStyle::prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &pai
if (!fill_pattern) {
switch (fill.type) {
case PAINT_SERVER: {
- NRRect pb(paintbox);
- fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), &pb, fill.opacity);
+ fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), paintbox, fill.opacity);
} break;
case PAINT_COLOR: {
SPColor const &c = fill.color;
@@ -176,8 +174,7 @@ bool NRStyle::prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &p
if (!stroke_pattern) {
switch (stroke.type) {
case PAINT_SERVER: {
- NRRect pb(paintbox);
- stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), &pb, stroke.opacity);
+ stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), paintbox, stroke.opacity);
} break;
case PAINT_COLOR: {
SPColor const &c = stroke.color;
diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp
index b4d2633bb..f4f0c485a 100644
--- a/src/display/sodipodi-ctrl.cpp
+++ b/src/display/sodipodi-ctrl.cpp
@@ -112,7 +112,7 @@ sp_ctrl_init (SPCtrl *ctrl)
// If moveto() is called then it will not set _moved to true because we're initially already at (0, 0)
ctrl->_moved = true; // Is this flag ever going to be set back to false? I can't find where that is supposed to happen
- ctrl->box.x0 = ctrl->box.y0 = ctrl->box.x1 = ctrl->box.y1 = 0;
+ new (&ctrl->box) Geom::IntRect(0,0,0,0);
ctrl->cache = NULL;
ctrl->pixbuf = NULL;
@@ -232,7 +232,7 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla
if (!ctrl->_moved) return;
if (ctrl->shown) {
- sp_canvas_request_redraw (item->canvas, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1);
+ sp_canvas_request_redraw (item->canvas, ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1);
}
if (!ctrl->defined) return;
@@ -278,12 +278,8 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla
break;
}
- ctrl->box.x0 = x;
- ctrl->box.y0 = y;
- ctrl->box.x1 = ctrl->box.x0 + 2 * ctrl->span;
- ctrl->box.y1 = ctrl->box.y0 + 2 * ctrl->span;
-
- sp_canvas_update_bbox (item, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1);
+ ctrl->box = Geom::IntRect::from_xywh(x, y, 2*ctrl->span, 2*ctrl->span);
+ sp_canvas_update_bbox (item, ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1);
}
static double
@@ -293,11 +289,7 @@ sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
*actual_item = item;
- double const x = p[Geom::X];
- double const y = p[Geom::Y];
-
- if ((x >= ctrl->box.x0) && (x <= ctrl->box.x1) && (y >= ctrl->box.y0) && (y <= ctrl->box.y1)) return 0.0;
-
+ if (ctrl->box.contains(p.floor())) return 0.0;
return 1e18;
}
@@ -519,8 +511,8 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf)
// 1. Copy the affected part of output to a temporary surface
cairo_surface_t *work = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
cairo_t *cr = cairo_create(work);
- cairo_translate(cr, -ctrl->box.x0, -ctrl->box.y0);
- cairo_set_source_surface(cr, cairo_get_target(buf->ct), buf->rect.x0, buf->rect.y0);
+ cairo_translate(cr, -ctrl->box.left(), -ctrl->box.top());
+ cairo_set_source_surface(cr, cairo_get_target(buf->ct), buf->rect.left(), buf->rect.top());
cairo_paint(cr);
cairo_destroy(cr);
@@ -551,8 +543,8 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf)
// 3. Replace the affected part of output with contents of temporary surface
cairo_save(buf->ct);
cairo_set_source_surface(buf->ct, work,
- ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0);
- cairo_rectangle(buf->ct, ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0, w, h);
+ ctrl->box.left() - buf->rect.left(), ctrl->box.top() - buf->rect.top());
+ cairo_rectangle(buf->ct, ctrl->box.left() - buf->rect.left(), ctrl->box.top() - buf->rect.top(), w, h);
cairo_clip(buf->ct);
cairo_set_operator(buf->ct, CAIRO_OPERATOR_SOURCE);
cairo_paint(buf->ct);
@@ -562,7 +554,7 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf)
cairo_surface_t *cache = cairo_image_surface_create_for_data(
reinterpret_cast<unsigned char*>(ctrl->cache), CAIRO_FORMAT_ARGB32, w, h, w*4);
cairo_set_source_surface(buf->ct, cache,
- ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0);
+ ctrl->box.left() - buf->rect.left(), ctrl->box.top() - buf->rect.top());
cairo_paint(buf->ct);
cairo_surface_destroy(cache);
}
diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h
index 4f114eac6..2617e7db2 100644
--- a/src/display/sodipodi-ctrl.h
+++ b/src/display/sodipodi-ctrl.h
@@ -9,7 +9,6 @@
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <libnr/nr-rect-l.h>
#include "sp-canvas-item.h"
@@ -48,7 +47,7 @@ struct SPCtrl : public SPCanvasItem {
guint32 stroke_color;
bool _moved;
- NRRectL box; /* NB! x1 & y1 are included */
+ Geom::IntRect box; /* NB! x1 & y1 are included */
guint32 *cache;
GdkPixbuf * pixbuf;
diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp
index b4539841b..c0e08c00a 100644
--- a/src/display/sodipodi-ctrlrect.cpp
+++ b/src/display/sodipodi-ctrlrect.cpp
@@ -132,7 +132,7 @@ void CtrlRect::render(SPCanvasBuf *buf)
if ( area_w_shadow.intersects(buf->rect) )
{
cairo_save(buf->ct);
- cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0);
+ cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top());
cairo_set_line_width(buf->ct, 1);
if (_dashed) cairo_set_dash(buf->ct, dashes, 2, 0);
cairo_rectangle(buf->ct, 0.5 + area[X].min(), 0.5 + area[Y].min(),
diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp
index d1ea842fd..78936009b 100644
--- a/src/display/sp-canvas-util.cpp
+++ b/src/display/sp-canvas-util.cpp
@@ -38,15 +38,8 @@ sp_canvas_item_reset_bounds (SPCanvasItem *item)
item->y2 = 0.0;
}
-void sp_canvas_prepare_buffer(SPCanvasBuf * /*buf*/)
+void sp_canvas_prepare_buffer(SPCanvasBuf *)
{
- /*if (buf->is_empty) {
- int y;
- for (y = buf->rect.y0; y < buf->rect.y1; y++) {
- memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, 0, 4 * (buf->rect.x1 - buf->rect.x0));
- }
- buf->is_empty = false;
- }*/
}
Geom::Affine sp_canvas_item_i2p_affine (SPCanvasItem * item)
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 7d6727ff3..a4c8500ed 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -866,10 +866,10 @@ sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf)
for (GList *list = group->items; list; list = list->next) {
SPCanvasItem *child = (SPCanvasItem *)list->data;
if (child->flags & SP_CANVAS_ITEM_VISIBLE) {
- if ((child->x1 < buf->rect.x1) &&
- (child->y1 < buf->rect.y1) &&
- (child->x2 > buf->rect.x0) &&
- (child->y2 > buf->rect.y0)) {
+ if ((child->x1 < buf->rect.right()) &&
+ (child->y1 < buf->rect.bottom()) &&
+ (child->x2 > buf->rect.left()) &&
+ (child->y2 > buf->rect.top())) {
if (SP_CANVAS_ITEM_GET_CLASS (child)->render)
SP_CANVAS_ITEM_GET_CLASS (child)->render (child, buf);
}
@@ -963,8 +963,8 @@ static gint sp_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event);
static GtkWidgetClass *canvas_parent_class;
static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb);
-static void sp_canvas_dirty_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb);
-static void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8_t val);
+static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area);
+static void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val);
static int do_update (SPCanvas *canvas);
/**
@@ -1634,46 +1634,38 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
return status;
}
-static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int x1, int y1, int draw_x1, int draw_y1, int draw_x2, int draw_y2, int /*sw*/)
+static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/)
{
GtkWidget *widget = GTK_WIDGET (canvas);
// Mark the region clean
- sp_canvas_mark_rect(canvas, x0, y0, x1, y1, 0);
+ sp_canvas_mark_rect(canvas, paint_rect, 0);
SPCanvasBuf buf;
buf.buf = NULL;
buf.buf_rowstride = 0;
- buf.rect.x0 = x0;
- buf.rect.y0 = y0;
- buf.rect.x1 = x1;
- buf.rect.y1 = y1;
- buf.visible_rect.x0 = draw_x1;
- buf.visible_rect.y0 = draw_y1;
- buf.visible_rect.x1 = draw_x2;
- buf.visible_rect.y1 = draw_y2;
+ buf.rect = paint_rect;
+ buf.visible_rect = canvas_rect;
buf.is_empty = true;
//buf.ct = gdk_cairo_create(widget->window);
/*
cairo_t *xctt = gdk_cairo_create(widget->window);
- cairo_translate(xctt, x0 - canvas->x0, y0 - canvas->y0);
+ cairo_translate(xctt, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0);
cairo_set_source_rgb(xctt, 1,0,0);
- cairo_rectangle(xctt, 0, 0, x1-x0, y1-y0);
+ cairo_rectangle(xctt, 0, 0, paint_rect.width(), paint_rect.height());
cairo_fill(xctt);
cairo_destroy(xctt);
//*/
// create temporary surface
- int w = x1 - x0;
- int h = y1 - y0;
- cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x1 - x0, y1 - y0);
+ cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, paint_rect.width(), paint_rect.height());
buf.ct = cairo_create(imgs);
//cairo_translate(buf.ct, -x0, -y0);
// fix coordinates, clip all drawing to the tile and clear the background
- //cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0);
- //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0);
+ //cairo_translate(buf.ct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0);
+ //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rect.height());
//cairo_set_line_width(buf.ct, 3);
//cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1);
//cairo_stroke_preserve(buf.ct);
@@ -1681,7 +1673,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int
gdk_cairo_set_source_color(buf.ct, &widget->style->bg[GTK_STATE_NORMAL]);
cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE);
- //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0);
+ //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rec.height());
cairo_paint(buf.ct);
cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER);
@@ -1707,9 +1699,9 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int
cairo_surface_flush(imgs);
unsigned char *px = cairo_image_surface_get_data(imgs);
int stride = cairo_image_surface_get_stride(imgs);
- for (int i=0; i<h; ++i) {
+ for (int i=0; i<paint_rect.height(); ++i) {
unsigned char *row = px + i*stride;
- Inkscape::CMSSystem::doTransform(transf, row, row, w);
+ Inkscape::CMSSystem::doTransform(transf, row, row, paint_rect.height());
}
cairo_surface_mark_dirty(imgs);
}
@@ -1717,8 +1709,8 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int
#endif // ENABLE_LCMS
cairo_t *xct = gdk_cairo_create(widget->window);
- cairo_translate(xct, x0 - canvas->x0, y0 - canvas->y0);
- cairo_rectangle(xct, 0, 0, x1-x0, y1-y0);
+ cairo_translate(xct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0);
+ cairo_rectangle(xct, 0, 0, paint_rect.width(), paint_rect.height());
cairo_clip(xct);
cairo_set_source_surface(xct, imgs, 0, 0);
cairo_set_operator(xct, CAIRO_OPERATOR_SOURCE);
@@ -1734,7 +1726,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int
struct PaintRectSetup {
SPCanvas* canvas;
- NRRectL big_rect;
+ Geom::IntRect big_rect;
GTimeVal start_time;
int max_pixels;
Geom::Point mouse_loc;
@@ -1747,7 +1739,7 @@ struct PaintRectSetup {
* @return true if the drawing completes
*/
static int
-sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect)
+sp_canvas_paint_rect_internal (PaintRectSetup const *setup, Geom::IntRect const &this_rect)
{
GTimeVal now;
g_get_current_time (&now);
@@ -1782,8 +1774,8 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect)
}
// Find the optimal buffer dimensions
- int bw = this_rect.x1 - this_rect.x0;
- int bh = this_rect.y1 - this_rect.y0;
+ int bw = this_rect.width();
+ int bh = this_rect.height();
if ((bw < 1) || (bh < 1))
return 0;
@@ -1799,16 +1791,12 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect)
gdk_window_begin_paint_rect(window, &r);*/
sp_canvas_paint_single_buffer (setup->canvas,
- this_rect.x0, this_rect.y0,
- this_rect.x1, this_rect.y1,
- setup->big_rect.x0, setup->big_rect.y0,
- setup->big_rect.x1, setup->big_rect.y1, bw);
+ this_rect, setup->big_rect, bw);
//gdk_window_end_paint(window);
return 1;
}
- NRRectL lo = this_rect;
- NRRectL hi = this_rect;
+ Geom::IntRect lo, hi;
/*
This test determines the redraw strategy:
@@ -1826,13 +1814,12 @@ faster.
The default for now is the strips mode.
*/
if (bw < bh || bh < 2 * TILE_SIZE) {
- // to correctly calculate the mean of two ints, we need to sum them into a larger int type
- int mid = ((long long) this_rect.x0 + (long long) this_rect.x1) / 2;
+ int mid = this_rect[Geom::X].middle();
// Make sure that mid lies on a tile boundary
mid = (mid / TILE_SIZE) * TILE_SIZE;
- lo.x1 = mid;
- hi.x0 = mid;
+ lo = Geom::IntRect(this_rect.left(), this_rect.top(), mid, this_rect.bottom());
+ hi = Geom::IntRect(mid, this_rect.top(), this_rect.right(), this_rect.bottom());
if (setup->mouse_loc[Geom::X] < mid) {
// Always paint towards the mouse first
@@ -1843,13 +1830,12 @@ The default for now is the strips mode.
&& sp_canvas_paint_rect_internal(setup, lo);
}
} else {
- // to correctly calculate the mean of two ints, we need to sum them into a larger int type
- int mid = ((long long) this_rect.y0 + (long long) this_rect.y1) / 2;
+ int mid = this_rect[Geom::Y].middle();
// Make sure that mid lies on a tile boundary
mid = (mid / TILE_SIZE) * TILE_SIZE;
- lo.y1 = mid;
- hi.y0 = mid;
+ lo = Geom::IntRect(this_rect.left(), this_rect.top(), this_rect.right(), mid);
+ hi = Geom::IntRect(this_rect.left(), mid, this_rect.right(), this_rect.bottom());
if (setup->mouse_loc[Geom::Y] < mid) {
// Always paint towards the mouse first
@@ -1873,22 +1859,19 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
{
g_return_val_if_fail (!canvas->need_update, false);
- NRRectL rect;
- rect.x0 = xx0;
- rect.x1 = xx1;
- rect.y0 = yy0;
- rect.y1 = yy1;
+ Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0,
+ GTK_WIDGET (canvas)->allocation.width, GTK_WIDGET (canvas)->allocation.height);
+ Geom::IntRect paint_rect(xx0, yy0, xx1, yy1);
- // Clip rect-to-draw by the current visible area
- rect.x0 = MAX (rect.x0, canvas->x0);
- rect.y0 = MAX (rect.y0, canvas->y0);
- rect.x1 = MIN (rect.x1, canvas->x0/*draw_x1*/ + GTK_WIDGET (canvas)->allocation.width);
- rect.y1 = MIN (rect.y1, canvas->y0/*draw_y1*/ + GTK_WIDGET (canvas)->allocation.height);
+ Geom::OptIntRect area = paint_rect & canvas_rect;
+ if (!area || area->hasZeroArea()) return 0;
+
+ paint_rect = *area;
PaintRectSetup setup;
setup.canvas = canvas;
- setup.big_rect = rect;
+ setup.big_rect = paint_rect;
// Save the mouse location
gint x, y;
@@ -1909,7 +1892,7 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
g_get_current_time(&(setup.start_time));
// Go
- return sp_canvas_paint_rect_internal(&setup, rect);
+ return sp_canvas_paint_rect_internal(&setup, paint_rect);
}
/**
@@ -1950,14 +1933,11 @@ sp_canvas_expose (GtkWidget *widget, GdkEventExpose *event)
gdk_region_get_rectangles (event->region, &rects, &n_rects);
for (int i = 0; i < n_rects; i++) {
- NRRectL rect;
-
- rect.x0 = rects[i].x + canvas->x0;
- rect.y0 = rects[i].y + canvas->y0;
- rect.x1 = rect.x0 + rects[i].width;
- rect.y1 = rect.y0 + rects[i].height;
+ Geom::IntRect r = Geom::IntRect::from_xywh(
+ rects[i].x + canvas->x0, rects[i].y + canvas->y0,
+ rects[i].width, rects[i].height);
- sp_canvas_request_redraw (canvas, rect.x0, rect.y0, rect.x1, rect.y1);
+ sp_canvas_request_redraw (canvas, r.left(), r.top(), r.right(), r.bottom());
}
if (n_rects > 0)
@@ -2225,30 +2205,21 @@ sp_canvas_request_update (SPCanvas *canvas)
void
sp_canvas_request_redraw (SPCanvas *canvas, int x0, int y0, int x1, int y1)
{
- NRRectL bbox;
- NRRectL visible;
- NRRectL clip;
-
g_return_if_fail (canvas != NULL);
g_return_if_fail (SP_IS_CANVAS (canvas));
if (!gtk_widget_is_drawable ( GTK_WIDGET (canvas))) return;
if ((x0 >= x1) || (y0 >= y1)) return;
- bbox.x0 = x0;
- bbox.y0 = y0;
- bbox.x1 = x1;
- bbox.y1 = y1;
-
- visible.x0 = canvas->x0;
- visible.y0 = canvas->y0;
- visible.x1 = visible.x0 + GTK_WIDGET (canvas)->allocation.width;
- visible.y1 = visible.y0 + GTK_WIDGET (canvas)->allocation.height;
-
- nr_rect_l_intersect (&clip, &bbox, &visible);
-
- sp_canvas_dirty_rect(canvas, clip.x0, clip.y0, clip.x1, clip.y1);
- add_idle (canvas);
+ Geom::IntRect bbox(x0, y0, x1, y1);
+ Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0,
+ GTK_WIDGET (canvas)->allocation.width, GTK_WIDGET (canvas)->allocation.height);
+
+ Geom::OptIntRect clip = bbox & canvas_rect;
+ if (clip) {
+ sp_canvas_dirty_rect(canvas, *clip);
+ add_idle (canvas);
+ }
}
/**
@@ -2386,24 +2357,21 @@ static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int
/*
* Helper that queues a canvas rectangle for redraw
*/
-static void sp_canvas_dirty_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb) {
+static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area) {
canvas->need_redraw = TRUE;
- sp_canvas_mark_rect(canvas, nl, nt, nr, nb, 1);
+ sp_canvas_mark_rect(canvas, area, 1);
}
/**
* Helper that marks specific canvas rectangle as clean (val == 0) or dirty (otherwise)
*/
-void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8_t val)
+void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val)
{
- if ( nl >= nr || nt >= nb ) {
- return;
- }
- int tl=sp_canvas_tile_floor(nl);
- int tt=sp_canvas_tile_floor(nt);
- int tr=sp_canvas_tile_ceil(nr);
- int tb=sp_canvas_tile_ceil(nb);
+ int tl=sp_canvas_tile_floor(area.left());
+ int tt=sp_canvas_tile_floor(area.top());
+ int tr=sp_canvas_tile_ceil(area.right());
+ int tb=sp_canvas_tile_ceil(area.bottom());
if ( tl >= canvas->tRight || tr <= canvas->tLeft || tt >= canvas->tBottom || tb <= canvas->tTop ) return;
if ( tl < canvas->tLeft ) tl=canvas->tLeft;
if ( tr > canvas->tRight ) tr=canvas->tRight;
diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h
index f284afdf2..bffa5e4e9 100644
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
@@ -30,12 +30,8 @@
#include <glib/gtypes.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-
#include <glibmm/ustring.h>
-
#include <2geom/affine.h>
-#include <libnr/nr-rect-l.h>
-
#include <2geom/rect.h>
G_BEGIN_DECLS
@@ -60,8 +56,8 @@ enum {
*/
struct SPCanvasBuf {
cairo_t *ct;
- NRRectL rect;
- NRRectL visible_rect;
+ Geom::IntRect rect;
+ Geom::IntRect visible_rect;
unsigned char *buf;
int buf_rowstride;
diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp
index c185234d4..cf70f324e 100644
--- a/src/display/sp-ctrlline.cpp
+++ b/src/display/sp-ctrlline.cpp
@@ -113,8 +113,8 @@ sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf)
Geom::Point s = cl->s * cl->affine;
Geom::Point e = cl->e * cl->affine;
- cairo_move_to (buf->ct, s[Geom::X] - buf->rect.x0, s[Geom::Y] - buf->rect.y0);
- cairo_line_to (buf->ct, e[Geom::X] - buf->rect.x0, e[Geom::Y] - buf->rect.y0);
+ cairo_move_to (buf->ct, s[Geom::X] - buf->rect.left(), s[Geom::Y] - buf->rect.top());
+ cairo_line_to (buf->ct, e[Geom::X] - buf->rect.left(), e[Geom::Y] - buf->rect.top());
cairo_stroke(buf->ct);
}
diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp
index 1cf7dded0..3a29b9b7c 100644
--- a/src/display/sp-ctrlpoint.cpp
+++ b/src/display/sp-ctrlpoint.cpp
@@ -105,7 +105,7 @@ sp_ctrlpoint_render (SPCanvasItem *item, SPCanvasBuf *buf)
Geom::Point pt = cp->pt * cp->affine;
- cairo_arc(buf->ct, pt[Geom::X] - buf->rect.x0, pt[Geom::Y] - buf->rect.y0, cp->radius, 0.0, 2 * M_PI);
+ cairo_arc(buf->ct, pt[Geom::X] - buf->rect.left(), pt[Geom::Y] - buf->rect.top(), cp->radius, 0.0, 2 * M_PI);
cairo_stroke(buf->ct);
}
diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp
index b39886178..8cdd8170b 100644
--- a/src/display/sp-ctrlquadr.cpp
+++ b/src/display/sp-ctrlquadr.cpp
@@ -97,15 +97,13 @@ sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf)
{
SPCtrlQuadr *cq = SP_CTRLQUADR (item);
- //Geom::Rect area (Geom::Point(buf->rect.x0, buf->rect.y0), Geom::Point(buf->rect.x1, buf->rect.y1));
-
if (!buf->ct)
return;
// RGB / BGR
cairo_new_path(buf->ct);
- Geom::Point min = Geom::Point(buf->rect.x0, buf->rect.y0);
+ Geom::Point min = buf->rect.min();
Geom::Point p1 = (cq->p1 * cq->affine) - min;
Geom::Point p2 = (cq->p2 * cq->affine) - min;
diff --git a/src/document.cpp b/src/document.cpp
index 72f92bd17..d45041296 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -534,7 +534,7 @@ gdouble SPDocument::getWidth() const
gdouble result = root->width.computed;
if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) {
- result = root->viewBox.x1 - root->viewBox.x0;
+ result = root->viewBox.width();
}
return result;
}
@@ -542,7 +542,7 @@ gdouble SPDocument::getWidth() const
void SPDocument::setWidth(gdouble width, const SPUnit *unit)
{
if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox=
- root->viewBox.x1 = root->viewBox.x0 + sp_units_get_pixels (width, *unit);
+ root->viewBox.setMax(Geom::Point(root->viewBox.left() + sp_units_get_pixels (width, *unit), root->viewBox.bottom()));
} else { // set to width=
gdouble old_computed = root->width.computed;
root->width.computed = sp_units_get_pixels (width, *unit);
@@ -557,16 +557,28 @@ void SPDocument::setWidth(gdouble width, const SPUnit *unit)
}
if (root->viewBox_set)
- root->viewBox.x1 = root->viewBox.x0 + (root->width.computed / old_computed) * (root->viewBox.x1 - root->viewBox.x0);
+ root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom()));
}
root->updateRepr();
}
+gdouble SPDocument::getHeight() const
+{
+ g_return_val_if_fail(this->priv != NULL, 0.0);
+ g_return_val_if_fail(this->root != NULL, 0.0);
+
+ gdouble result = root->height.computed;
+ if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) {
+ result = root->viewBox.height();
+ }
+ return result;
+}
+
void SPDocument::setHeight(gdouble height, const SPUnit *unit)
{
if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox=
- root->viewBox.y1 = root->viewBox.y0 + sp_units_get_pixels (height, *unit);
+ root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + sp_units_get_pixels (height, *unit)));
} else { // set to height=
gdouble old_computed = root->height.computed;
root->height.computed = sp_units_get_pixels (height, *unit);
@@ -581,24 +593,12 @@ void SPDocument::setHeight(gdouble height, const SPUnit *unit)
}
if (root->viewBox_set)
- root->viewBox.y1 = root->viewBox.y0 + (root->height.computed / old_computed) * (root->viewBox.y1 - root->viewBox.y0);
+ root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height()));
}
root->updateRepr();
}
-gdouble SPDocument::getHeight() const
-{
- g_return_val_if_fail(this->priv != NULL, 0.0);
- g_return_val_if_fail(this->root != NULL, 0.0);
-
- gdouble result = root->height.computed;
- if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) {
- result = root->viewBox.y1 - root->viewBox.y0;
- }
- return result;
-}
-
Geom::Point SPDocument::getDimensions() const
{
return Geom::Point(getWidth(), getHeight());
@@ -941,15 +941,9 @@ void SPDocument::setupViewport(SPItemCtx *ctx)
ctx->i2doc = Geom::identity();
// Set up viewport in case svg has it defined as percentages
if (root->viewBox_set) { // if set, take from viewBox
- ctx->vp.x0 = root->viewBox.x0;
- ctx->vp.y0 = root->viewBox.y0;
- ctx->vp.x1 = root->viewBox.x1;
- ctx->vp.y1 = root->viewBox.y1;
+ ctx->viewport = root->viewBox;
} else { // as a last resort, set size to A4
- ctx->vp.x0 = 0.0;
- ctx->vp.y0 = 0.0;
- ctx->vp.x1 = 210 * PX_PER_MM;
- ctx->vp.y1 = 297 * PX_PER_MM;
+ ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * PX_PER_MM, 297 * PX_PER_MM);
}
ctx->i2vp = Geom::identity();
}
@@ -1086,7 +1080,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey,
s = find_items_in_area(s, SP_GROUP(o), dkey, area, test);
} else {
SPItem *child = SP_ITEM(o);
- Geom::OptRect box = child->getBboxDesktop();
+ Geom::OptRect box = child->desktopVisualBounds();
if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
s = g_slist_append(s, child);
}
diff --git a/src/document.h b/src/document.h
index c94b66c4d..83cb57eea 100644
--- a/src/document.h
+++ b/src/document.h
@@ -38,7 +38,6 @@ namespace Avoid {
class Router;
}
-struct NRRect;
struct SPDesktop;
struct SPItem;
struct SPObject;
diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp
index 9fbbcdc27..d91642bd2 100644
--- a/src/dropper-context.cpp
+++ b/src/dropper-context.cpp
@@ -225,25 +225,15 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
Geom::Rect r(dc->centre, dc->centre);
r.expandBy(rw);
if (!r.hasZeroArea()) {
- NRRectL area;
- area.x0 = r[Geom::X].min();
- area.y0 = r[Geom::Y].min();
- area.x1 = r[Geom::X].max();
- area.y1 = r[Geom::Y].max();
- int w = area.x1 - area.x0;
- int h = area.y1 - area.y0;
- cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
+ Geom::IntRect area = r.roundOutwards();
+ cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, area.width(), area.height());
sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area);
ink_cairo_surface_average_color_premul(s, R, G, B, A);
cairo_surface_destroy(s);
}
} else {
// pick single pixel
- NRRectL area;
- area.x0 = floor(event->button.x);
- area.y0 = floor(event->button.y);
- area.x1 = area.x0 + 1;
- area.y1 = area.y0 + 1;
+ Geom::IntRect area = Geom::IntRect::from_xywh(floor(event->button.x), floor(event->button.y), 1, 1);
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area);
ink_cairo_surface_average_color_premul(s, R, G, B, A);
diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp
index a3a665b1c..5bc258dbc 100644
--- a/src/dyna-draw-context.cpp
+++ b/src/dyna-draw-context.cpp
@@ -441,11 +441,7 @@ sp_dyna_draw_brush(SPDynaDrawContext *dc)
if (dc->trace_bg) {
// pick single pixel
double R, G, B, A;
- NRRectL area;
- area.x0 = floor(brush_w[Geom::X]);
- area.y0 = floor(brush_w[Geom::Y]);
- area.x1 = area.x0 + 1;
- area.y1 = area.y0 + 1;
+ Geom::IntRect area = Geom::IntRect::from_xywh(brush_w.floor(), Geom::IntPoint(1, 1));
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(SP_EVENT_CONTEXT(dc)->desktop)), s, area);
ink_cairo_surface_average_color_premul(s, R, G, B, A);
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index de6c7d86f..11b150aa0 100644
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
@@ -748,7 +748,7 @@ set_to_accumulated(SPEraserContext *dc)
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr));
- Geom::OptRect eraserBbox = acid->getBounds(Geom::identity());
+ Geom::OptRect eraserBbox = acid->visualBounds();
Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt();
std::vector<SPItem*> remainingItems;
GSList* toWorkOn = 0;
@@ -770,7 +770,7 @@ set_to_accumulated(SPEraserContext *dc)
for (GSList *i = toWorkOn ; i ; i = i->next ) {
SPItem *item = SP_ITEM(i->data);
if ( eraserMode ) {
- Geom::OptRect bbox = item->getBounds(Geom::identity());
+ Geom::OptRect bbox = item->visualBounds();
if (bbox && bbox->intersects(*eraserBbox)) {
Inkscape::XML::Node* dup = dc->repr->duplicate(xml_doc);
dc->repr->parent()->appendChild(dup);
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index 1e6577173..b4f42a37d 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -157,16 +157,14 @@ desktop_ensure_active (SPDesktop* desk) {
gdouble
selection_get_center_x (Inkscape::Selection *sel){
- NRRect *box = g_new(NRRect, 1);;
- box = sel->boundsInDocument(box);
- return box->x0 + ((box->x1 - box->x0)/2);
+ Geom::OptRect box = sel->documentBounds(SPItem::GEOMETRIC_BBOX);
+ return box ? box->midpoint()[Geom::X] : 0;
}
gdouble
selection_get_center_y (Inkscape::Selection *sel){
- NRRect *box = g_new(NRRect, 1);;
- box = sel->boundsInDocument(box);
- return box->y0 + ((box->y1 - box->y0)/2);
+ Geom::OptRect box = sel->documentBounds(SPItem::GEOMETRIC_BBOX);
+ return box ? box->midpoint()[Geom::X] : 0;
}
/*
diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp
index e01eb760a..b42caca06 100644
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
@@ -355,21 +355,15 @@ Effect::set_pref_dialog (PrefDialog * prefdialog)
return;
}
-/** \brief Create an action for a \c EffectVerb
- \param view Which view the action should be created for
- \return The built action.
-
- Calls \c make_action_helper with the \c vector.
-*/
SPAction *
Effect::EffectVerb::make_action (Inkscape::UI::View::View * view)
{
- return make_action_helper(view, &vector, static_cast<void *>(this));
+ return make_action_helper(view, &perform, static_cast<void *>(this));
}
/** \brief Decode the verb code and take appropriate action */
void
-Effect::EffectVerb::perform( SPAction *action, void * data, void */*pdata*/ )
+Effect::EffectVerb::perform( SPAction *action, void * data )
{
Inkscape::UI::View::View * current_view = sp_action_get_view(action);
// SPDocument * current_document = current_view->doc;
@@ -388,14 +382,6 @@ Effect::EffectVerb::perform( SPAction *action, void * data, void */*pdata*/ )
return;
}
-/**
- * Action vector to define functions called if a staticly defined file verb
- * is called.
- */
-SPActionEventVector Effect::EffectVerb::vector =
- {{NULL}, Effect::EffectVerb::perform, NULL, NULL, NULL, NULL};
-
-
} } /* namespace Inkscape, Extension */
/*
diff --git a/src/extension/effect.h b/src/extension/effect.h
index 28ebc5d96..61a826ad4 100644
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
@@ -53,9 +53,7 @@ class Effect : public Extension {
back to the effect that created it. */
class EffectVerb : public Inkscape::Verb {
private:
- static void perform (SPAction * action, void * mydata, void * otherdata);
- /** \brief Function to call for specific actions */
- static SPActionEventVector vector;
+ static void perform (SPAction * action, void * mydata);
/** \brief The effect that this verb represents. */
Effect * _effect;
diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp
index 63181d0c4..6f6bddb93 100644
--- a/src/extension/implementation/implementation.cpp
+++ b/src/extension/implementation/implementation.cpp
@@ -29,72 +29,15 @@ namespace Inkscape {
namespace Extension {
namespace Implementation {
-/**
- * \return Was the load sucessful?
- * \brief This function is the stub load. It just returns success.
- * \param module The Extension that should be loaded.
- */
-bool
-Implementation::load(Inkscape::Extension::Extension */*module*/) {
- return TRUE;
-} /* Implementation::load */
-
-void
-Implementation::unload(Inkscape::Extension::Extension */*module*/) {
- return;
-} /* Implementation::unload */
-
-/** \brief Create a new document cache object
- \param ext The extension that is referencing us
- \param doc The document to create the cache of
- \return A new document cache that is valid as long as the document
- is not changed.
-
- This function just returns \c NULL. Subclasses are likely
- to reimplement it to do something useful.
-*/
-ImplementationDocumentCache *
-Implementation::newDocCache( Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * /*view*/ ) {
- return NULL;
-}
-
-bool
-Implementation::check(Inkscape::Extension::Extension */*module*/) {
- /* If there are no checks, they all pass */
- return TRUE;
-} /* Implemenation::check */
-
-bool
-Implementation::cancelProcessing (void) {
- return true;
-}
-
-void
-Implementation::commitDocument (void) {
- return;
-}
-
Gtk::Widget *
Implementation::prefs_input(Inkscape::Extension::Input *module, gchar const */*filename*/) {
return module->autogui(NULL, NULL);
-} /* Implementation::prefs_input */
-
-SPDocument *
-Implementation::open(Inkscape::Extension::Input */*module*/, gchar const */*filename*/) {
- /* throw open_failed(); */
- return NULL;
-} /* Implementation::open */
+}
Gtk::Widget *
Implementation::prefs_output(Inkscape::Extension::Output *module) {
return module->autogui(NULL, NULL);
-} /* Implementation::prefs_output */
-
-void
-Implementation::save(Inkscape::Extension::Output */*module*/, SPDocument */*doc*/, gchar const */*filename*/) {
- /* throw save_fail */
- return;
-} /* Implementation::save */
+}
Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, ImplementationDocumentCache * /*docCache*/)
{
@@ -117,119 +60,6 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I
return module->autogui(current_document, const_cast<Inkscape::XML::Node *>(first_select), changeSignal);
} // Implementation::prefs_effect
-void
-Implementation::effect(Inkscape::Extension::Effect */*module*/, Inkscape::UI::View::View */*document*/, ImplementationDocumentCache * /*docCache*/) {
- /* throw filter_fail */
- return;
-} /* Implementation::filter */
-
-unsigned int
-Implementation::setup(Inkscape::Extension::Print */*module*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::set_preview(Inkscape::Extension::Print */*module*/)
-{
- return 0;
-}
-
-
-unsigned int
-Implementation::begin(Inkscape::Extension::Print */*module*/, SPDocument */*doc*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::finish(Inkscape::Extension::Print */*module*/)
-{
- return 0;
-}
-
-
-/* Rendering methods */
-unsigned int
-Implementation::bind(Inkscape::Extension::Print */*module*/, Geom::Affine const */*transform*/, float /*opacity*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::release(Inkscape::Extension::Print */*module*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::comment(Inkscape::Extension::Print */*module*/, char const */*comment*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::fill(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Affine const */*ctm*/, SPStyle const */*style*/,
- NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::stroke(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Affine const */*transform*/, SPStyle const */*style*/,
- NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::image(Inkscape::Extension::Print */*module*/, unsigned char */*px*/, unsigned int /*w*/, unsigned int /*h*/, unsigned int /*rs*/,
- Geom::Affine const */*transform*/, SPStyle const */*style*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::text(Inkscape::Extension::Print */*module*/, char const */*text*/,
- Geom::Point /*p*/, SPStyle const */*style*/)
-{
- return 0;
-}
-
-void
-Implementation::processPath(Inkscape::XML::Node * /*node*/)
-{
- return;
-}
-
-/**
- \brief Tell the printing engine whether text should be text or path
- \retval true Render the text as a path
- \retval false Render text using the text function (above)
-
- Default value is false because most printing engines will support
- paths more than they'll support text. (at least they do today)
-*/
-bool
-Implementation::textToPath(Inkscape::Extension::Print */*ext*/)
-{
- return false;
-}
-
-/**
- \brief Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded
- \retval TRUE Fonts have to be embedded in the output so that the user might not need to install fonts to have the interpreter read the document correctly
- \retval FALSE Not embed fonts
-
- Only available for Adobe Type 1 fonts in EPS output as of now
-*/
-
-bool
-Implementation::fontEmbedded(Inkscape::Extension::Print * /*ext*/)
-{
- return false;
-}
-
} /* namespace Implementation */
} /* namespace Extension */
} /* namespace Inkscape */
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index bd3edb43b..a09f7c863 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -9,8 +9,8 @@
important for implementing the extensions themselves. This file
contains the base class for all of that.
*/
-#ifndef __INKSCAPE_EXTENSION_IMPLEMENTATION_H__
-#define __INKSCAPE_EXTENSION_IMPLEMENTATION_H__
+#ifndef SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H
+#define SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H
#include <gtk/gtk.h>
#include <gdkmm/types.h>
@@ -18,7 +18,6 @@
#include "forward.h"
#include "extension/extension-forward.h"
-#include "libnr/nr-forward.h"
#include "xml/node.h"
#include <2geom/forward.h>
#include <2geom/point.h>
@@ -54,16 +53,23 @@ public:
virtual ~Implementation() {}
/* ----- Basic functions for all Extension ----- */
- virtual bool load(Inkscape::Extension::Extension *module);
-
- virtual void unload(Inkscape::Extension::Extension *module);
- virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc);
+ virtual bool load(Inkscape::Extension::Extension *module) { return true; }
+
+ virtual void unload(Inkscape::Extension::Extension *module) {}
+ /** \brief Create a new document cache object
+ * This function just returns \c NULL. Subclasses are likely
+ * to reimplement it to do something useful.
+ * \param ext The extension that is referencing us
+ * \param doc The document to create the cache of
+ * \return A new document cache that is valid as long as the document
+ * is not changed. */
+ virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc) { return NULL; }
/** Verify any dependencies. */
- virtual bool check(Inkscape::Extension::Extension *module);
+ virtual bool check(Inkscape::Extension::Extension *module) { return true; }
- virtual bool cancelProcessing (void);
- virtual void commitDocument (void);
+ virtual bool cancelProcessing () { return true; }
+ virtual void commitDocument () {}
/* ----- Input functions ----- */
/** Find out information about the file. */
@@ -71,65 +77,75 @@ public:
gchar const *filename);
virtual SPDocument *open(Inkscape::Extension::Input *module,
- gchar const *filename);
+ gchar const *filename) { return NULL; }
/* ----- Output functions ----- */
/** Find out information about the file. */
virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module);
- virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename);
+ virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename) {}
/* ----- Effect functions ----- */
/** Find out information about the file. */
virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module,
- Inkscape::UI::View::View * view,
- sigc::signal<void> * changeSignal,
- ImplementationDocumentCache * docCache);
+ Inkscape::UI::View::View *view,
+ sigc::signal<void> *changeSignal,
+ ImplementationDocumentCache *docCache);
virtual void effect(Inkscape::Extension::Effect *module,
Inkscape::UI::View::View *document,
- ImplementationDocumentCache * docCache);
+ ImplementationDocumentCache *docCache) {}
/* ----- Print functions ----- */
- virtual unsigned setup(Inkscape::Extension::Print *module);
- virtual unsigned set_preview(Inkscape::Extension::Print *module);
+ virtual unsigned setup(Inkscape::Extension::Print *module) { return 0; }
+ virtual unsigned set_preview(Inkscape::Extension::Print *module) { return 0; }
virtual unsigned begin(Inkscape::Extension::Print *module,
- SPDocument *doc);
- virtual unsigned finish(Inkscape::Extension::Print *module);
- virtual bool textToPath(Inkscape::Extension::Print *ext);
- virtual bool fontEmbedded(Inkscape::Extension::Print * ext);
+ SPDocument *doc) { return 0; }
+ virtual unsigned finish(Inkscape::Extension::Print *module) { return 0; }
+ /** \brief Tell the printing engine whether text should be text or path
+ * Default value is false because most printing engines will support
+ * paths more than they'll support text. (at least they do today)
+ * \retval true Render the text as a path
+ * \retval false Render text using the text function (above) */
+ virtual bool textToPath(Inkscape::Extension::Print *ext) { return false; }
+ /** \brief Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded
+ * Only available for Adobe Type 1 fonts in EPS output as of now
+ * \retval true Fonts have to be embedded in the output so that the user might not need
+ * to install fonts to have the interpreter read the document correctly
+ * \retval false Do not embed fonts */
+ virtual bool fontEmbedded(Inkscape::Extension::Print * ext) { return false; }
/* ----- Rendering methods ----- */
virtual unsigned bind(Inkscape::Extension::Print *module,
- Geom::Affine const *transform,
- float opacity);
- virtual unsigned release(Inkscape::Extension::Print *module);
- virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment);
+ Geom::Affine const &transform,
+ float opacity) { return 0; }
+ virtual unsigned release(Inkscape::Extension::Print *module) { return 0; }
+ virtual unsigned comment(Inkscape::Extension::Print *module, char const *comment) { return 0; }
virtual unsigned fill(Inkscape::Extension::Print *module,
Geom::PathVector const &pathv,
- Geom::Affine const *ctm,
+ Geom::Affine const &ctm,
SPStyle const *style,
- NRRect const *pbox,
- NRRect const *dbox,
- NRRect const *bbox);
+ Geom::OptRect const &pbox,
+ Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox) { return 0; }
virtual unsigned stroke(Inkscape::Extension::Print *module,
Geom::PathVector const &pathv,
- Geom::Affine const *transform,
+ Geom::Affine const &transform,
SPStyle const *style,
- NRRect const *pbox,
- NRRect const *dbox,
- NRRect const *bbox);
+ Geom::OptRect const &pbox,
+ Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox) { return 0; }
virtual unsigned image(Inkscape::Extension::Print *module,
unsigned char *px,
unsigned int w,
unsigned int h,
unsigned int rs,
- Geom::Affine const *transform,
- SPStyle const *style);
+ Geom::Affine const &transform,
+ SPStyle const *style) { return 0; }
virtual unsigned text(Inkscape::Extension::Print *module,
char const *text,
- Geom::Point p,
- SPStyle const *style);
- virtual void processPath(Inkscape::XML::Node * node);
+ Geom::Point const &p,
+ SPStyle const *style) { return 0; }
+ virtual void processPath(Inkscape::XML::Node * node) {}
};
diff --git a/src/extension/internal/bitmap/crop.cpp b/src/extension/internal/bitmap/crop.cpp
index 23e31b510..2ad75a0dc 100644
--- a/src/extension/internal/bitmap/crop.cpp
+++ b/src/extension/internal/bitmap/crop.cpp
@@ -38,7 +38,7 @@ Crop::postEffect(Magick::Image *image, SPItem *item) {
sp_item_scale_rel (item, scale);
// Translate proportionaly to the image/bbox ratio
- Geom::OptRect bbox(item->getBboxDesktop());
+ Geom::OptRect bbox(item->desktopGeometricBounds());
//g_warning("bbox. W:%f, H:%f, X:%f, Y:%f", bbox->dimensions()[Geom::X], bbox->dimensions()[Geom::Y], bbox->min()[Geom::X], bbox->min()[Geom::Y]);
Geom::Translate translate (0,0);
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index c3a8a790b..9bafa9432 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -87,19 +87,19 @@
#define TEST(_args)
// FIXME: expose these from sp-clippath/mask.cpp
-struct SPClipPathView {
+/*struct SPClipPathView {
SPClipPathView *next;
unsigned int key;
Inkscape::DrawingItem *arenaitem;
- NRRect bbox;
+ Geom::OptRect bbox;
};
struct SPMaskView {
SPMaskView *next;
unsigned int key;
Inkscape::DrawingItem *arenaitem;
- NRRect bbox;
-};
+ Geom::OptRect bbox;
+};*/
namespace Inkscape {
namespace Extension {
@@ -682,12 +682,12 @@ CairoRenderContext::popLayer(void)
// copy the correct CTM to mask context
/*
if (_state->parent_has_userspace)
- mask_ctx->setTransform(&getParentState()->transform);
+ mask_ctx->setTransform(getParentState()->transform);
else
- mask_ctx->setTransform(&_state->transform);
+ mask_ctx->setTransform(_state->transform);
*/
// This is probably not correct... but it seems to do the trick.
- mask_ctx->setTransform(&_state->item_transform);
+ mask_ctx->setTransform(_state->item_transform);
// render mask contents to mask_ctx
_renderer->applyMask(mask_ctx, mask);
@@ -915,7 +915,7 @@ CairoRenderContext::finish(void)
}
void
-CairoRenderContext::transform(Geom::Affine const *transform)
+CairoRenderContext::transform(Geom::Affine const &transform)
{
g_assert( _is_valid );
@@ -924,42 +924,44 @@ CairoRenderContext::transform(Geom::Affine const *transform)
cairo_transform(_cr, &matrix);
// store new CTM
- getTransform(&_state->transform);
+ _state->transform = getTransform();
}
void
-CairoRenderContext::setTransform(Geom::Affine const *transform)
+CairoRenderContext::setTransform(Geom::Affine const &transform)
{
g_assert( _is_valid );
cairo_matrix_t matrix;
_initCairoMatrix(&matrix, transform);
cairo_set_matrix(_cr, &matrix);
- _state->transform = *transform;
+ _state->transform = transform;
}
-void
-CairoRenderContext::getTransform(Geom::Affine *copy) const
+Geom::Affine
+CairoRenderContext::getTransform() const
{
g_assert( _is_valid );
cairo_matrix_t ctm;
cairo_get_matrix(_cr, &ctm);
- (*copy)[0] = ctm.xx;
- (*copy)[1] = ctm.yx;
- (*copy)[2] = ctm.xy;
- (*copy)[3] = ctm.yy;
- (*copy)[4] = ctm.x0;
- (*copy)[5] = ctm.y0;
+ Geom::Affine ret;
+ ret[0] = ctm.xx;
+ ret[1] = ctm.yx;
+ ret[2] = ctm.xy;
+ ret[3] = ctm.yy;
+ ret[4] = ctm.x0;
+ ret[5] = ctm.y0;
+ return ret;
}
-void
-CairoRenderContext::getParentTransform(Geom::Affine *copy) const
+Geom::Affine
+CairoRenderContext::getParentTransform() const
{
g_assert( _is_valid );
CairoRenderState *parent_state = getParentState();
- memcpy(copy, &parent_state->transform, sizeof(Geom::Affine));
+ return parent_state->transform;
}
void
@@ -1002,7 +1004,7 @@ static bool pattern_hasItemChildren(SPPattern *pat)
}
cairo_pattern_t*
-CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox)
+CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox)
{
g_assert( SP_IS_PATTERN(paintserver) );
@@ -1023,10 +1025,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
if (pbox && pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
//Geom::Affine bbox2user (pbox->x1 - pbox->x0, 0.0, 0.0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);
- bbox_width_scaler = pbox->x1 - pbox->x0;
- bbox_height_scaler = pbox->y1 - pbox->y0;
- ps2user[4] = x * bbox_width_scaler + pbox->x0;
- ps2user[5] = y * bbox_height_scaler + pbox->y0;
+ bbox_width_scaler = pbox->width();
+ bbox_height_scaler = pbox->height();
+ ps2user[4] = x * bbox_width_scaler + pbox->left();
+ ps2user[5] = y * bbox_height_scaler + pbox->top();
} else {
bbox_width_scaler = 1.0;
bbox_height_scaler = 1.0;
@@ -1041,27 +1043,22 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
// create pattern contents coordinate system
if (pat->viewBox_set) {
- NRRect *view_box = pattern_viewBox(pat);
+ Geom::Rect view_box = *pattern_viewBox(pat);
double x, y, w, h;
- double view_width, view_height;
x = 0;
y = 0;
w = width * bbox_width_scaler;
h = height * bbox_height_scaler;
- view_width = view_box->x1 - view_box->x0;
- view_height = view_box->y1 - view_box->y0;
-
//calculatePreserveAspectRatio(pat->aspect_align, pat->aspect_clip, view_width, view_height, &x, &y, &w, &h);
- pcs2dev[0] = w / view_width;
- pcs2dev[3] = h / view_height;
- pcs2dev[4] = x - view_box->x0 * pcs2dev[0];
- pcs2dev[5] = y - view_box->y0 * pcs2dev[3];
+ pcs2dev[0] = w / view_box.width();
+ pcs2dev[3] = h / view_box.height();
+ pcs2dev[4] = x - view_box.left() * pcs2dev[0];
+ pcs2dev[5] = y - view_box.top() * pcs2dev[3];
} else if (pbox && pattern_patternContentUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
- pcs2dev[0] = pbox->x1 - pbox->x0;
- pcs2dev[3] = pbox->y1 - pbox->y0;
-
+ pcs2dev[0] = pbox->width();
+ pcs2dev[3] = pbox->height();
}
// Calculate the size of the surface which has to be created
@@ -1089,7 +1086,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
ps2user[4] = ori[Geom::X];
ps2user[5] = ori[Geom::Y];
- pattern_ctx->setTransform(&pcs2dev);
+ pattern_ctx->setTransform(pcs2dev);
pattern_ctx->pushState();
// create drawing and group
@@ -1119,7 +1116,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
// set pattern transformation
cairo_matrix_t pattern_matrix;
- _initCairoMatrix(&pattern_matrix, &ps2user);
+ _initCairoMatrix(&pattern_matrix, ps2user);
cairo_matrix_invert(&pattern_matrix);
cairo_pattern_set_matrix(result, &pattern_matrix);
@@ -1142,7 +1139,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
cairo_pattern_t*
CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const paintserver,
- NRRect const *pbox, float alpha)
+ Geom::OptRect const &pbox, float alpha)
{
cairo_pattern_t *pattern = NULL;
bool apply_bbox2user = FALSE;
@@ -1157,7 +1154,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
Geom::Point p2 (lg->x2.computed, lg->y2.computed);
if (pbox && SP_GRADIENT(lg)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
// convert to userspace
- Geom::Affine bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);
+ Geom::Affine bbox2user(pbox->width(), 0, 0, pbox->height(), pbox->left(), pbox->top());
p1 *= bbox2user;
p2 *= bbox2user;
}
@@ -1237,7 +1234,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
if (apply_bbox2user) {
// convert to userspace
cairo_matrix_t bbox2user;
- cairo_matrix_init (&bbox2user, pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);
+ cairo_matrix_init (&bbox2user, pbox->width(), 0, 0, pbox->height(), pbox->left(), pbox->top());
cairo_matrix_multiply (&pattern_matrix, &bbox2user, &pattern_matrix);
}
cairo_matrix_invert(&pattern_matrix); // because Cairo expects a userspace->patternspace matrix
@@ -1248,7 +1245,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
}
void
-CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox)
+CairoRenderContext::_setFillStyle(SPStyle const *const style, Geom::OptRect const &pbox)
{
g_return_if_fail( !style->fill.set
|| style->fill.isColor()
@@ -1284,7 +1281,7 @@ CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox
}
void
-CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox)
+CairoRenderContext::_setStrokeStyle(SPStyle const *style, Geom::OptRect const &pbox)
{
float alpha = SP_SCALE24_TO_FLOAT(style->stroke_opacity.value);
if (_state->merge_opacity)
@@ -1351,7 +1348,7 @@ CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox)
}
bool
-CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox)
+CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox)
{
g_assert( _is_valid );
@@ -1419,7 +1416,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
}
bool CairoRenderContext::renderImage(GdkPixbuf *pb,
- Geom::Affine const *image_transform, SPStyle const * /*style*/)
+ Geom::Affine const &image_transform, SPStyle const * /*style*/)
{
g_assert( _is_valid );
@@ -1442,8 +1439,7 @@ bool CairoRenderContext::renderImage(GdkPixbuf *pb,
cairo_save(_cr);
// scaling by width & height is not needed because it will be done by Cairo
- if (image_transform)
- transform(image_transform);
+ transform(image_transform);
cairo_set_source_surface(_cr, image_surface, 0.0, 0.0);
@@ -1507,7 +1503,7 @@ unsigned int CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont * /*font*/,
}
bool
-CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix,
+CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix,
std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style)
{
// create a cairo_font_face from PangoFont
@@ -1575,7 +1571,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma
stroke = true;
}
if (fill) {
- _setFillStyle(style, NULL);
+ _setFillStyle(style, Geom::OptRect());
if (_is_texttopath) {
_showGlyphs(_cr, font, glyphtext, true);
have_path = true;
@@ -1586,7 +1582,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma
}
}
if (stroke) {
- _setStrokeStyle(style, NULL);
+ _setStrokeStyle(style, Geom::OptRect());
if (!have_path) _showGlyphs(_cr, font, glyphtext, true);
cairo_stroke(_cr);
}
@@ -1625,22 +1621,22 @@ CairoRenderContext::_concatTransform(cairo_t *cr, double xx, double yx, double x
}
void
-CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const *transform)
+CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const &transform)
{
- matrix->xx = (*transform)[0];
- matrix->yx = (*transform)[1];
- matrix->xy = (*transform)[2];
- matrix->yy = (*transform)[3];
- matrix->x0 = (*transform)[4];
- matrix->y0 = (*transform)[5];
+ matrix->xx = transform[0];
+ matrix->yx = transform[1];
+ matrix->xy = transform[2];
+ matrix->yy = transform[3];
+ matrix->x0 = transform[4];
+ matrix->y0 = transform[5];
}
void
-CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Affine const *transform)
+CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Affine const &transform)
{
- _concatTransform(cr, (*transform)[0], (*transform)[1],
- (*transform)[2], (*transform)[3],
- (*transform)[4], (*transform)[5]);
+ _concatTransform(cr, transform[0], transform[1],
+ transform[2], transform[3],
+ transform[4], transform[5]);
}
static cairo_status_t
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index d4117ff7e..94c7bb294 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -128,20 +128,20 @@ public:
CairoRenderState *getParentState(void) const;
void setStateForStyle(SPStyle const *style);
- void transform(Geom::Affine const *transform);
- void setTransform(Geom::Affine const *transform);
- void getTransform(Geom::Affine *copy) const;
- void getParentTransform(Geom::Affine *copy) const;
+ void transform(Geom::Affine const &transform);
+ void setTransform(Geom::Affine const &transform);
+ Geom::Affine getTransform() const;
+ Geom::Affine getParentTransform() const;
/* Clipping methods */
void addClipPath(Geom::PathVector const &pv, SPIEnum const *fill_rule);
void addClippingRect(double x, double y, double width, double height);
/* Rendering methods */
- bool renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox);
+ bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox);
bool renderImage(GdkPixbuf *pb,
- Geom::Affine const *image_transform, SPStyle const *style);
- bool renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix,
+ Geom::Affine const &image_transform, SPStyle const *style);
+ bool renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix,
std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style);
/* More general rendering methods will have to be added (like fill, stroke) */
@@ -183,18 +183,18 @@ protected:
CairoClipMode _clip_mode;
cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver,
- NRRect const *pbox, float alpha);
- cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox);
+ Geom::OptRect const &pbox, float alpha);
+ cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox);
unsigned int _showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoGlyphInfo> const &glyphtext, bool is_stroke);
bool _finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t *ctm = NULL);
- void _setFillStyle(SPStyle const *style, NRRect const *pbox);
- void _setStrokeStyle(SPStyle const *style, NRRect const *pbox);
+ void _setFillStyle(SPStyle const *style, Geom::OptRect const &pbox);
+ void _setStrokeStyle(SPStyle const *style, Geom::OptRect const &pbox);
- void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const *transform);
+ void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const &transform);
void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0);
- void _concatTransform(cairo_t *cr, Geom::Affine const *transform);
+ void _concatTransform(cairo_t *cr, Geom::Affine const &transform);
GHashTable *font_table;
static void font_data_free(gpointer data);
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 5e7fb991a..3b6c26113 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -28,7 +28,6 @@
#include <signal.h>
#include <errno.h>
-#include "libnr/nr-rect.h"
#include "libnrtype/Layout-TNG.h"
#include <2geom/transforms.h>
#include <2geom/pathvector.h>
@@ -87,14 +86,14 @@ struct SPClipPathView {
SPClipPathView *next;
unsigned int key;
Inkscape::DrawingItem *arenaitem;
- NRRect bbox;
+ Geom::OptRect bbox;
};
struct SPMaskView {
SPMaskView *next;
unsigned int key;
Inkscape::DrawingItem *arenaitem;
- NRRect bbox;
+ Geom::OptRect bbox;
};
namespace Inkscape {
@@ -181,15 +180,13 @@ static void sp_shape_render_invoke_marker_rendering(SPMarker* marker, Geom::Affi
static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
{
- NRRect pbox;
-
SPShape *shape = SP_SHAPE(item);
if (!shape->curve) {
return;
}
- item->invoke_bbox( &pbox, Geom::identity(), TRUE);
+ Geom::OptRect pbox = item->geometricBounds();
SPStyle* style = item->style;
@@ -198,7 +195,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
return;
}
- ctx->renderPathVector(pathv, style, &pbox);
+ ctx->renderPathVector(pathv, style, pbox);
// START marker
for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START
@@ -316,7 +313,7 @@ static void sp_use_render(SPItem *item, CairoRenderContext *ctx)
if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) {
Geom::Affine tp(Geom::Translate(use->x.computed, use->y.computed));
ctx->pushState();
- ctx->transform(&tp);
+ ctx->transform(tp);
translated = true;
}
@@ -372,7 +369,7 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx)
Geom::Scale s(width / (double)w, height / (double)h);
Geom::Affine t(s * tp);
- ctx->renderImage (image->pixbuf, &t, item->style);
+ ctx->renderImage (image->pixbuf, t, item->style);
}
static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
@@ -384,7 +381,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
/* Cloned <symbol> is actually renderable */
ctx->pushState();
- ctx->transform(&symbol->c2p);
+ ctx->transform(symbol->c2p);
// apply viewbox if set
if (0 /*symbol->viewBox_set*/) {
@@ -396,8 +393,8 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
width = 1.0;
height = 1.0;
- view_width = symbol->viewBox.x1 - symbol->viewBox.x0;
- view_height = symbol->viewBox.y1 - symbol->viewBox.y0;
+ view_width = symbol->viewBox.width();
+ view_height = symbol->viewBox.height();
calculatePreserveAspectRatio(symbol->aspect_align, symbol->aspect_clip, view_width, view_height,
&x, &y,&width, &height);
@@ -406,10 +403,10 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
vb2user = Geom::identity();
vb2user[0] = width / view_width;
vb2user[3] = height / view_height;
- vb2user[4] = x - symbol->viewBox.x0 * vb2user[0];
- vb2user[5] = y - symbol->viewBox.y0 * vb2user[3];
+ vb2user[4] = x - symbol->viewBox.left() * vb2user[0];
+ vb2user[5] = y - symbol->viewBox.top() * vb2user[3];
- ctx->transform(&vb2user);
+ ctx->transform(vb2user);
}
sp_group_render(item, ctx);
@@ -425,8 +422,7 @@ static void sp_root_render(SPRoot *root, CairoRenderContext *ctx)
ctx->pushState();
renderer->setStateForItem(ctx, root);
- Geom::Affine tempmat (root->c2p);
- ctx->transform(&tempmat);
+ ctx->transform(root->c2p);
sp_group_render(root, ctx);
ctx->popState();
}
@@ -450,9 +446,8 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
}
TRACE(("sp_asbitmap_render: resolution: %f\n", res ));
- // Get the bounding box of the selection in document coordinates.
- Geom::OptRect bbox =
- item->getBounds(item->i2dt_affine(), SPItem::RENDERING_BBOX);
+ // Get the bounding box of the selection in desktop coordinates.
+ Geom::OptRect bbox = item->desktopVisualBounds();
// no bbox, e.g. empty group
if (!bbox) {
@@ -460,12 +455,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
}
Geom::Rect docrect(Geom::Rect(Geom::Point(0, 0), item->document->getDimensions()));
- Geom::Rect bboxrect(Geom::Rect(Geom::Point(bbox->min()[Geom::X], bbox->min()[Geom::Y]), Geom::Point(bbox->max()[Geom::X], bbox->max()[Geom::Y])));
-
- Geom::OptRect _bbox = Geom::intersect(docrect, bboxrect);
-
- // assign the object dimension clipped on the document, no need to draw on area not on canvas
- bbox = _bbox;
+ bbox &= docrect;
// no bbox, e.g. empty group
if (!bbox) {
@@ -473,14 +463,14 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
}
// The width and height of the bitmap in pixels
- unsigned width = ceil((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN));
- unsigned height = ceil((bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) * (res / PX_PER_IN));
+ unsigned width = ceil(bbox->width() * (res / PX_PER_IN));
+ unsigned height = ceil(bbox->height() * (res / PX_PER_IN));
if (width == 0 || height == 0) return;
// Scale to exactly fit integer bitmap inside bounding box
- double scale_x = (bbox->max()[Geom::X] - bbox->min()[Geom::X]) / width;
- double scale_y = (bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) / height;
+ double scale_x = bbox->width() / width;
+ double scale_y = bbox->height() / height;
// Location of bounding box in document coordinates.
double shift_x = bbox->min()[Geom::X];
@@ -516,7 +506,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL ));
// TODO this is stupid - we just converted to pixbuf format when generating the bitmap!
convert_pixbuf_normal_to_argb32(pb);
- ctx->renderImage(pb, &t, item->style);
+ ctx->renderImage(pb, t, item->style);
gdk_pixbuf_unref(pb);
pb = 0;
}
@@ -604,8 +594,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item)
state->merge_opacity = FALSE;
ctx->pushLayer();
}
- Geom::Affine tempmat (item->transform);
- ctx->transform(&tempmat);
+ ctx->transform(item->transform);
sp_item_invoke_render(item, ctx);
if (state->need_layer)
@@ -625,25 +614,25 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
base = doc->getRoot();
}
- NRRect d;
+ Geom::Rect d;
if (pageBoundingBox) {
- d.x0 = d.y0 = 0;
- d.x1 = doc->getWidth();
- d.y1 = doc->getHeight();
+ d = Geom::Rect::from_xywh(Geom::Point(0,0), doc->getDimensions());
} else {
- base->invoke_bbox( &d, base->i2dt_affine(), TRUE, SPItem::RENDERING_BBOX);
+ Geom::OptRect bbox = base->desktopVisualBounds();
+ if (!bbox) {
+ g_message("CairoRenderer: empty bounding box.");
+ return false;
+ }
+ d = *bbox;
}
if (ctx->_vector_based_target) {
// convert from px to pt
- d.x0 *= PT_PER_PX;
- d.x1 *= PT_PER_PX;
- d.y0 *= PT_PER_PX;
- d.y1 *= PT_PER_PX;
+ d *= Geom::Scale(PT_PER_PX);
}
- ctx->_width = d.x1-d.x0;
- ctx->_height = d.y1-d.y0;
+ ctx->_width = d.width();
+ ctx->_height = d.height();
TRACE(("setupDocument: %f x %f\n", ctx->_width, ctx->_height));
@@ -655,11 +644,12 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
if (ctx->_vector_based_target)
high *= PT_PER_PX;
- Geom::Affine tp(Geom::Translate(-d.x0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
- (d.y1 - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
- ctx->transform(&tp);
+ /// @fixme hardcoded dt2doc transform?
+ Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
+ (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ ctx->transform(tp);
}
-
+
return ret;
}
@@ -677,16 +667,17 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
CairoRenderContext::CairoRenderMode saved_mode = ctx->getRenderMode();
ctx->setRenderMode(CairoRenderContext::RENDER_MODE_CLIP);
+ // FIXME: the access to the first clippath view to obtain the bbox is completely bogus
Geom::Affine saved_ctm;
- if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) {
+ if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && cp->display->bbox) {
//SP_PRINT_DRECT("clipd", cp->display->bbox);
- NRRect clip_bbox(cp->display->bbox);
- Geom::Affine t(Geom::Scale(clip_bbox.x1 - clip_bbox.x0, clip_bbox.y1 - clip_bbox.y0));
- t[4] = clip_bbox.x0;
- t[5] = clip_bbox.y0;
+ Geom::Rect clip_bbox = *cp->display->bbox;
+ Geom::Affine t(Geom::Scale(clip_bbox.dimensions()));
+ t[4] = clip_bbox.left();
+ t[5] = clip_bbox.top();
t *= ctx->getCurrentState()->transform;
- ctx->getTransform(&saved_ctm);
- ctx->setTransform(&t);
+ saved_ctm = ctx->getTransform();
+ ctx->setTransform(t);
}
TRACE(("BEGIN clip\n"));
@@ -696,12 +687,11 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
SPItem const *item = SP_ITEM(child);
// combine transform of the item in clippath and the item using clippath:
- Geom::Affine tempmat (item->transform);
- tempmat = tempmat * (ctx->getCurrentState()->item_transform);
+ Geom::Affine tempmat = item->transform * ctx->getCurrentState()->item_transform;
// render this item in clippath
ctx->pushState();
- ctx->transform(&tempmat);
+ ctx->transform(tempmat);
setStateForItem(ctx, item);
// TODO fix this call to accept const items
sp_item_invoke_render(const_cast<SPItem *>(item), ctx);
@@ -716,7 +706,7 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
cairo_clip(ctx->_cr);
if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX)
- ctx->setTransform(&saved_ctm);
+ ctx->setTransform(saved_ctm);
ctx->setRenderMode(saved_mode);
}
@@ -730,15 +720,16 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask)
if (mask == NULL)
return;
- //SP_PRINT_DRECT("maskd", &mask->display->bbox);
- NRRect mask_bbox(mask->display->bbox);
+ // FIXME: the access to the first mask view to obtain the bbox is completely bogus
// TODO: should the bbox be transformed if maskUnits != userSpaceOnUse ?
- if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) {
- Geom::Affine t(Geom::Scale(mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0));
- t[4] = mask_bbox.x0;
- t[5] = mask_bbox.y0;
+ if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && mask->display->bbox) {
+ //SP_PRINT_DRECT("maskd", &mask->display->bbox);
+ Geom::Rect mask_bbox = *mask->display->bbox;
+ Geom::Affine t(Geom::Scale(mask_bbox.dimensions()));
+ t[4] = mask_bbox.left();
+ t[5] = mask_bbox.top();
t *= ctx->getCurrentState()->transform;
- ctx->setTransform(&t);
+ ctx->setTransform(t);
}
// Clip mask contents... but...
diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp
index 7ed0f6fcf..d08304a00 100644
--- a/src/extension/internal/emf-win32-print.cpp
+++ b/src/extension/internal/emf-win32-print.cpp
@@ -135,25 +135,22 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
_width = doc->getWidth();
_height = doc->getHeight();
- NRRect d;
bool pageBoundingBox;
pageBoundingBox = mod->get_param_bool("pageBoundingBox");
+
+ Geom::Rect d;
if (pageBoundingBox) {
- d.x0 = d.y0 = 0;
- d.x1 = _width;
- d.y1 = _height;
+ d = Geom::Rect::from_xywh(0, 0, _width, _height);
} else {
SPItem* doc_item = doc->getRoot();
- doc_item->invoke_bbox(&d, doc_item->i2dt_affine(), TRUE);
+ Geom::OptRect bbox = doc_item->desktopVisualBounds();
+ if (bbox) d = *bbox;
}
- d.x0 *= IN_PER_PX;
- d.y0 *= IN_PER_PX;
- d.x1 *= IN_PER_PX;
- d.y1 *= IN_PER_PX;
+ d *= IN_PER_PX;
- float dwInchesX = (d.x1 - d.x0);
- float dwInchesY = (d.y1 - d.y0);
+ float dwInchesX = d.width();
+ float dwInchesY = d.height();
// dwInchesX x dwInchesY in .01mm units
SetRect( &rc, 0, 0, (int) ceil(dwInchesX*2540), (int) ceil(dwInchesY*2540) );
@@ -451,15 +448,13 @@ PrintEmfWin32::flush_fill()
}
unsigned int
-PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const *transform, float /*opacity*/)
-{
- Geom::Affine tr = *transform;
-
+PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/)
+{
if (m_tr_stack.size()) {
Geom::Affine tr_top = m_tr_stack.top();
- m_tr_stack.push(tr * tr_top);
+ m_tr_stack.push(transform * tr_top);
} else {
- m_tr_stack.push(tr);
+ m_tr_stack.push(transform);
}
return 1;
@@ -474,8 +469,8 @@ PrintEmfWin32::release(Inkscape::Extension::Print * /*mod*/)
unsigned int
PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/,
- Geom::PathVector const &pathv, Geom::Affine const * /*transform*/, SPStyle const *style,
- NRRect const * /*pbox*/, NRRect const * /*dbox*/, NRRect const * /*bbox*/)
+ Geom::PathVector const &pathv, Geom::Affine const & /*transform*/, SPStyle const *style,
+ Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/)
{
if (!hdc) return 0;
@@ -503,8 +498,8 @@ PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/,
unsigned int
PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/,
- Geom::PathVector const &pathv, const Geom::Affine * /*transform*/, const SPStyle *style,
- const NRRect * /*pbox*/, const NRRect * /*dbox*/, const NRRect * /*bbox*/)
+ Geom::PathVector const &pathv, const Geom::Affine &/*transform*/, const SPStyle *style,
+ Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/)
{
if (!hdc) return 0;
@@ -849,7 +844,7 @@ PrintEmfWin32::textToPath(Inkscape::Extension::Print * ext)
}
unsigned int
-PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point p,
+PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point const &p,
SPStyle const *const style)
{
if (!hdc) return 0;
diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h
index 44327d35e..71ce5d6d0 100644
--- a/src/extension/internal/emf-win32-print.h
+++ b/src/extension/internal/emf-win32-print.h
@@ -62,17 +62,21 @@ public:
virtual unsigned int finish (Inkscape::Extension::Print * module);
/* Rendering methods */
- virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const *transform, float opacity);
+ virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const &transform, float opacity);
virtual unsigned int release(Inkscape::Extension::Print *module);
- virtual unsigned int fill (Inkscape::Extension::Print * module,
- Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
+ virtual unsigned int fill (Inkscape::Extension::Print *module,
+ Geom::PathVector const &pathv,
+ Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
virtual unsigned int stroke (Inkscape::Extension::Print * module,
- Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
+ Geom::PathVector const &pathv,
+ Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment);
virtual unsigned int text(Inkscape::Extension::Print *module, char const *text,
- Geom::Point p, SPStyle const *style);
+ Geom::Point const &p, SPStyle const *style);
bool textToPath (Inkscape::Extension::Print * ext);
static void init (void);
diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp
index 6436624fd..da5ea6d9e 100644
--- a/src/extension/internal/grid.cpp
+++ b/src/extension/internal/grid.cpp
@@ -90,7 +90,7 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
bounding_area = Geom::Rect( Geom::Point(0,0),
Geom::Point(doc->getWidth(), doc->getHeight()) );
} else {
- Geom::OptRect bounds = selection->bounds();
+ Geom::OptRect bounds = selection->visualBounds();
if (bounds) {
bounding_area = *bounds;
}
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index 18950295c..49304de96 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -164,15 +164,14 @@ PrintLatex::finish (Inkscape::Extension::Print *mod)
}
unsigned int
-PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const *transform, float opacity)
+PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const &transform, float opacity)
{
- Geom::Affine tr = *transform;
-
- if(m_tr_stack.size()){
+ if (m_tr_stack.size()) {
Geom::Affine tr_top = m_tr_stack.top();
- m_tr_stack.push(tr * tr_top);
- }else
- m_tr_stack.push(tr);
+ m_tr_stack.push(transform * tr_top);
+ } else {
+ m_tr_stack.push(transform);
+ }
return 1;
}
@@ -194,8 +193,8 @@ unsigned int PrintLatex::comment (Inkscape::Extension::Print * module,
unsigned int
PrintLatex::fill(Inkscape::Extension::Print *mod,
- Geom::PathVector const &pathv, Geom::Affine const *transform, SPStyle const *style,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
+ Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
@@ -227,8 +226,9 @@ PrintLatex::fill(Inkscape::Extension::Print *mod,
}
unsigned int
-PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox)
+PrintLatex::stroke (Inkscape::Extension::Print *mod,
+ Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
@@ -277,12 +277,12 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pat
// FIXME: why is 'transform' argument not used?
void
-PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine * /*transform*/)
+PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine & /*transform*/)
{
if (pathv_in.empty())
return;
-// Geom::Affine tf=*transform; // why was this here?
+// Geom::Affine tf=transform; // why was this here?
Geom::Affine tf_stack=m_tr_stack.top(); // and why is transform argument not used?
Geom::PathVector pathv = pathv_in * tf_stack; // generates new path, which is a bit slow, but this doesn't have to be performance optimized
@@ -304,7 +304,7 @@ PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv
}
void
-PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c )
+PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const &c)
{
using Geom::X;
using Geom::Y;
diff --git a/src/extension/internal/latex-pstricks.h b/src/extension/internal/latex-pstricks.h
index 64b0de474..5bc6eeb22 100644
--- a/src/extension/internal/latex-pstricks.h
+++ b/src/extension/internal/latex-pstricks.h
@@ -33,7 +33,7 @@ class PrintLatex : public Inkscape::Extension::Implementation::Implementation {
std::stack<Geom::Affine> m_tr_stack;
- void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine * /*transform*/);
+ void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine & /*transform*/);
void print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c );
public:
@@ -47,13 +47,17 @@ public:
virtual unsigned int finish (Inkscape::Extension::Print * module);
/* Rendering methods */
- virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const *transform, float opacity);
+ virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const &transform, float opacity);
virtual unsigned int release(Inkscape::Extension::Print *module);
- virtual unsigned int fill (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
- virtual unsigned int stroke (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
+ virtual unsigned int fill (Inkscape::Extension::Print *module, Geom::PathVector const &pathv,
+ Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
+ virtual unsigned int stroke (Inkscape::Extension::Print *module, Geom::PathVector const &pathv,
+ Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment);
bool textToPath (Inkscape::Extension::Print * ext);
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index 02f0823d9..0da048a17 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -588,27 +588,27 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
base = doc->getRoot();
}
- Geom::OptRect d;
+ Geom::Rect d;
if (pageBoundingBox) {
- d = Geom::Rect( Geom::Point(0,0),
- Geom::Point(doc->getWidth(), doc->getHeight()) );
+ d = Geom::Rect::from_xywh(Geom::Point(0,0), doc->getDimensions());
} else {
- base->invoke_bbox( d, base->i2dt_affine(), TRUE, SPItem::RENDERING_BBOX);
- }
- if (!d) {
- g_message("LaTeXTextRenderer: could not retrieve boundingbox.");
- return false;
+ Geom::OptRect bbox = base->desktopVisualBounds();
+ if (!bbox) {
+ g_message("CairoRenderer: empty bounding box.");
+ return false;
+ }
+ d = *bbox;
}
// scale all coordinates, such that the width of the image is 1, this is convenient for scaling the image in LaTeX
- double scale = 1/(d->width());
- double _width = d->width() * scale;
- double _height = d->height() * scale;
+ double scale = 1/(d.width());
+ double _width = d.width() * scale;
+ double _height = d.height() * scale;
push_transform( Geom::Scale(scale, scale) );
if (!pageBoundingBox)
{
- push_transform( Geom::Translate( - d->min() ) );
+ push_transform( Geom::Translate( -d.min() ) );
}
// flip y-axis
@@ -621,7 +621,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
// scaling of the image when including it in LaTeX
os << " \\ifx\\svgwidth\\undefined%\n";
- os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
+ os << " \\setlength{\\unitlength}{" << d.width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
os << " \\ifx\\svgscale\\undefined%\n";
os << " \\relax%\n";
os << " \\else%\n";
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index 568c804a0..735c57798 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -573,7 +573,7 @@ void SingularValueDecomposition::calculate()
//double eps = pow(2.0,-52.0);
//double tiny = pow(2.0,-966.0);
//let's just calculate these now
- //a double can be e ± 308.25, so this is safe
+ //a double can be e ± 308.25, so this is safe
double eps = 2.22e-16;
double tiny = 1.6e-291;
while (p > 0) {
@@ -965,15 +965,10 @@ static Geom::Affine getODFTransform(const SPItem *item)
*/
static Geom::OptRect getODFBoundingBox(const SPItem *item)
{
- Geom::OptRect bbox_temp = ((SPItem *)item)->getBboxDesktop();
- Geom::OptRect bbox;
- if (bbox_temp) {
- bbox = *bbox_temp;
- double doc_height = SP_ACTIVE_DOCUMENT->getHeight();
- Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0));
- doc2dt_tf = doc2dt_tf * Geom::Affine(Geom::Translate(0, doc_height));
- bbox = *bbox * doc2dt_tf;
- bbox = *bbox * Geom::Affine(Geom::Scale(pxToCm));
+ // TODO: geometric or visual?
+ Geom::OptRect bbox = ((SPItem *)item)->documentVisualBounds();
+ if (bbox) {
+ *bbox *= Geom::Affine(Geom::Scale(pxToCm));
}
return bbox;
}
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index dc995b7aa..fe383b920 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -37,7 +37,6 @@
#include "io/stringstream.h"
#include "io/base64stream.h"
#include "display/nr-filter-utils.h"
-#include "libnr/nr-macros.h"
#include "libnrtype/font-instance.h"
#include "Function.h"
diff --git a/src/extension/print.cpp b/src/extension/print.cpp
index f2dbb0b9b..c37e9425c 100644
--- a/src/extension/print.cpp
+++ b/src/extension/print.cpp
@@ -15,7 +15,7 @@
namespace Inkscape {
namespace Extension {
-Print::Print (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp)
+Print::Print (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp)
: Extension(in_repr, in_imp)
, base(NULL)
, drawing(NULL)
@@ -24,23 +24,23 @@ Print::Print (Inkscape::XML::Node * in_repr, Implementation::Implementation * in
{
}
-Print::~Print (void)
+Print::~Print ()
{}
bool
-Print::check (void)
+Print::check ()
{
return Extension::check();
}
unsigned int
-Print::setup (void)
+Print::setup ()
{
return imp->setup(this);
}
unsigned int
-Print::set_preview (void)
+Print::set_preview ()
{
return imp->set_preview(this);
}
@@ -52,65 +52,65 @@ Print::begin (SPDocument *doc)
}
unsigned int
-Print::finish (void)
+Print::finish ()
{
return imp->finish(this);
}
unsigned int
-Print::bind (const Geom::Affine *transform, float opacity)
+Print::bind (const Geom::Affine &transform, float opacity)
{
return imp->bind (this, transform, opacity);
}
unsigned int
-Print::release (void)
+Print::release ()
{
return imp->release(this);
}
unsigned int
-Print::comment (const char * comment)
+Print::comment (char const *comment)
{
- return imp->comment(this,comment);
+ return imp->comment(this, comment);
}
unsigned int
-Print::fill (Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox)
+Print::fill (Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
return imp->fill (this, pathv, ctm, style, pbox, dbox, bbox);
}
unsigned int
-Print::stroke (Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox)
+Print::stroke (Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
- return imp->stroke (this, pathv, transform, style, pbox, dbox, bbox);
+ return imp->stroke (this, pathv, ctm, style, pbox, dbox, bbox);
}
unsigned int
Print::image (unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
- const Geom::Affine *transform, const SPStyle *style)
+ const Geom::Affine &transform, const SPStyle *style)
{
return imp->image (this, px, w, h, rs, transform, style);
}
unsigned int
-Print::text (const char* text, Geom::Point p, const SPStyle* style)
+Print::text (char const *text, Geom::Point const &p, SPStyle const *style)
{
return imp->text (this, text, p, style);
}
bool
-Print::textToPath (void)
+Print::textToPath ()
{
return imp->textToPath(this);
}
//whether embed font in print output (EPS especially)
bool
-Print::fontEmbedded (void)
+Print::fontEmbedded ()
{
return imp->fontEmbedded(this);
}
diff --git a/src/extension/print.h b/src/extension/print.h
index c2276126b..9c0920499 100644
--- a/src/extension/print.h
+++ b/src/extension/print.h
@@ -41,30 +41,30 @@ public:
unsigned int finish (void);
/* Rendering methods */
- unsigned int bind (Geom::Affine const *transform,
+ unsigned int bind (Geom::Affine const &transform,
float opacity);
unsigned int release (void);
unsigned int comment (const char * comment);
unsigned int fill (Geom::PathVector const &pathv,
- Geom::Affine const *ctm,
+ Geom::Affine const &ctm,
SPStyle const *style,
- NRRect const *pbox,
- NRRect const *dbox,
- NRRect const *bbox);
+ Geom::OptRect const &pbox,
+ Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
unsigned int stroke (Geom::PathVector const &pathv,
- Geom::Affine const *transform,
+ Geom::Affine const &transform,
SPStyle const *style,
- NRRect const *pbox,
- NRRect const *dbox,
- NRRect const *bbox);
+ Geom::OptRect const &pbox,
+ Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
unsigned int image (unsigned char *px,
unsigned int w,
unsigned int h,
unsigned int rs,
- Geom::Affine const *transform,
+ Geom::Affine const &transform,
SPStyle const *style);
unsigned int text (char const *text,
- Geom::Point p,
+ Geom::Point const &p,
SPStyle const *style);
bool textToPath (void);
bool fontEmbedded (void);
diff --git a/src/file.cpp b/src/file.cpp
index c6d43fa51..350281dee 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -1056,7 +1056,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
// move to mouse pointer
{
sp_desktop_document(desktop)->ensureUpToDate();
- Geom::OptRect sel_bbox = selection->bounds();
+ Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
sp_selection_move_relative(selection, m, false);
diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp
index 9ea9407b1..1b63bf6f9 100644
--- a/src/filter-chemistry.cpp
+++ b/src/filter-chemistry.cpp
@@ -317,7 +317,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo
SPFilter *
new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mode, gdouble radius)
{
- Geom::OptRect const r = item->getBboxDesktop(SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect const r = item->desktopGeometricBounds();
double width;
double height;
@@ -370,7 +370,7 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it
stdDeviation /= expansion;
// Get the object size
- Geom::OptRect const r = item->getBboxDesktop(SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect const r = item->desktopGeometricBounds();
double width;
double height;
if (r) {
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index 8603f8b66..9e8705862 100644
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -778,7 +778,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
document->ensureUpToDate();
- Geom::OptRect bbox = document->getRoot()->getBounds(Geom::identity());
+ Geom::OptRect bbox = document->getRoot()->visualBounds();
if (!bbox) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Area is not bounded</b>, cannot fill."));
diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp
index f803d7bf8..990695068 100644
--- a/src/gradient-chemistry.cpp
+++ b/src/gradient-chemistry.cpp
@@ -16,6 +16,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <2geom/transforms.h>
+#include <2geom/bezier-curve.h>
#include "style.h"
#include "document-private.h"
@@ -30,14 +32,12 @@
#include "sp-text.h"
#include "sp-tspan.h"
-#include <2geom/transforms.h>
#include "xml/repr.h"
#include "svg/svg.h"
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
#include "preferences.h"
-#include "libnr/nr-point-fns.h"
#define noSP_GR_VERBOSE
// Terminology:
@@ -296,7 +296,7 @@ SPGradient *sp_gradient_reset_to_userspace(SPGradient *gr, SPItem *item)
// calculate the bbox of the item
item->document->ensureUpToDate();
- Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine
+ Geom::OptRect bbox = item->visualBounds(); // we need "true" bbox without item_i2d_affine
if (!bbox)
return gr;
@@ -363,7 +363,7 @@ SPGradient *sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar
// calculate the bbox of the item
item->document->ensureUpToDate();
Geom::Affine bbox2user;
- Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine
+ Geom::OptRect bbox = item->visualBounds(); // we need "true" bbox without item_i2d_affine
if ( bbox ) {
bbox2user = Geom::Affine(bbox->dimensions()[Geom::X], 0,
0, bbox->dimensions()[Geom::Y],
@@ -838,7 +838,9 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i,
case POINT_LG_MID:
{
// using X-coordinates only to determine the offset, assuming p has been snapped to the vector from begin to end.
- double offset = get_offset_between_points (p, Geom::Point(lg->x1.computed, lg->y1.computed), Geom::Point(lg->x2.computed, lg->y2.computed));
+ Geom::Point begin(lg->x1.computed, lg->y1.computed);
+ Geom::Point end(lg->x2.computed, lg->y2.computed);
+ double offset = Geom::LineSegment(begin, end).nearestPoint(p);
SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (lg, false);
lg->ensureVector();
lg->vector.stops.at(point_i).offset = offset;
@@ -931,8 +933,8 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i,
case POINT_RG_MID1:
{
Geom::Point start = Geom::Point (rg->cx.computed, rg->cy.computed);
- Geom::Point end = Geom::Point (rg->cx.computed + rg->r.computed, rg->cy.computed);
- double offset = get_offset_between_points (p, start, end);
+ Geom::Point end = Geom::Point (rg->cx.computed + rg->r.computed, rg->cy.computed);
+ double offset = Geom::LineSegment(start, end).nearestPoint(p);
SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (rg, false);
rg->ensureVector();
rg->vector.stops.at(point_i).offset = offset;
@@ -948,7 +950,7 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i,
case POINT_RG_MID2:
Geom::Point start = Geom::Point (rg->cx.computed, rg->cy.computed);
Geom::Point end = Geom::Point (rg->cx.computed, rg->cy.computed - rg->r.computed);
- double offset = get_offset_between_points (p, start, end);
+ double offset = Geom::LineSegment(start, end).nearestPoint(p);
SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(rg, false);
rg->ensureVector();
rg->vector.stops.at(point_i).offset = offset;
@@ -1063,7 +1065,7 @@ Geom::Point sp_item_gradient_get_coords(SPItem *item, guint point_type, guint po
if (SP_GRADIENT(gradient)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
item->document->ensureUpToDate();
- Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine
+ Geom::OptRect bbox = item->visualBounds(); // we need "true" bbox without item_i2d_affine
if (bbox) {
p *= Geom::Affine(bbox->dimensions()[Geom::X], 0,
0, bbox->dimensions()[Geom::Y],
diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp
index c4bef4683..0cb000003 100644
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
@@ -46,8 +46,6 @@
#include "sp-namedview.h"
#include "rubberband.h"
-#include "libnr/nr-point-fns.h"
-
using Inkscape::DocumentUndo;
static void sp_gradient_context_class_init(SPGradientContextClass *klass);
@@ -254,7 +252,8 @@ sp_gradient_context_is_over_line (SPGradientContext *rc, SPItem *item, Geom::Poi
SPCtrlLine* line = SP_CTRLLINE(item);
- Geom::Point nearest = snap_vector_midpoint (rc->mousepoint_doc, line->s, line->e, 0);
+ Geom::LineSegment ls(line->s, line->e);
+ Geom::Point nearest = ls.pointAt(ls.nearestPoint(rc->mousepoint_doc));
double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom();
double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance;
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 142ae2a98..585c55c28 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -20,6 +20,7 @@
#include <glibmm/i18n.h>
#include <cstring>
#include <string>
+#include <2geom/bezier-curve.h>
#include "desktop-handles.h"
#include "selection.h"
@@ -32,7 +33,6 @@
#include "xml/repr.h"
#include "svg/css-ostringstream.h"
#include "svg/svg.h"
-#include "libnr/nr-point-fns.h"
#include "preferences.h"
#include "sp-item.h"
#include "style.h"
@@ -339,7 +339,7 @@ guint32 GrDrag::getColor()
SPStop *
GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance)
{
- gfloat offset; // type of SPStop.offset = gfloat
+ gfloat offset = 0; // type of SPStop.offset = gfloat
SPGradient *gradient;
bool fill_or_stroke = true;
bool r1_knot = false;
@@ -350,32 +350,34 @@ GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance)
if (SP_IS_LINEARGRADIENT(gradient)) {
Geom::Point begin = sp_item_gradient_get_coords(item, POINT_LG_BEGIN, 0, fill_or_stroke);
Geom::Point end = sp_item_gradient_get_coords(item, POINT_LG_END, 0, fill_or_stroke);
-
- Geom::Point nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- double dist_screen = Geom::L2 (mouse_p - nearest);
+ Geom::LineSegment ls(begin, end);
+ double offset = ls.nearestPoint(mouse_p);
+ Geom::Point nearest = ls.pointAt(offset);
+ double dist_screen = Geom::distance(mouse_p, nearest);
if ( dist_screen < tolerance ) {
// add the knot
- offset = get_offset_between_points(nearest, begin, end);
addknot = true;
break; // break out of the while loop: add only one knot
}
} else if (SP_IS_RADIALGRADIENT(gradient)) {
Geom::Point begin = sp_item_gradient_get_coords(item, POINT_RG_CENTER, 0, fill_or_stroke);
Geom::Point end = sp_item_gradient_get_coords(item, POINT_RG_R1, 0, fill_or_stroke);
- Geom::Point nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- double dist_screen = Geom::L2 (mouse_p - nearest);
+ Geom::LineSegment ls(begin, end);
+ double offset = ls.nearestPoint(mouse_p);
+ Geom::Point nearest = ls.pointAt(offset);
+ double dist_screen = Geom::distance(mouse_p, nearest);
if ( dist_screen < tolerance ) {
- offset = get_offset_between_points(nearest, begin, end);
addknot = true;
r1_knot = true;
break; // break out of the while loop: add only one knot
}
end = sp_item_gradient_get_coords(item, POINT_RG_R2, 0, fill_or_stroke);
- nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- dist_screen = Geom::L2 (mouse_p - nearest);
+ ls = Geom::LineSegment(begin, end);
+ offset = ls.nearestPoint(mouse_p);
+ nearest = ls.pointAt(offset);
+ dist_screen = Geom::distance(mouse_p, nearest);
if ( dist_screen < tolerance ) {
- offset = get_offset_between_points(nearest, begin, end);
addknot = true;
r1_knot = false;
break; // break out of the while loop: add only one knot
@@ -442,7 +444,8 @@ GrDrag::dropColor(SPItem */*item*/, gchar const *c, Geom::Point p)
if (lines) {
for (GSList *l = lines; (l != NULL) && (!over_line); l = l->next) {
line = (SPCtrlLine*) l->data;
- Geom::Point nearest = snap_vector_midpoint (p, line->s, line->e, 0);
+ Geom::LineSegment ls(line->s, line->e);
+ Geom::Point nearest = ls.pointAt(ls.nearestPoint(p));
double dist_screen = Geom::L2 (p - nearest) * desktop->current_zoom();
if (line->item && dist_screen < 5) {
SPStop *stop = addStopNearPoint (line->item, p, 5/desktop->current_zoom());
@@ -847,9 +850,11 @@ gr_knot_moved_midpoint_handler(SPKnot */*knot*/, Geom::Point const &ppointer, gu
gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, &moving);
if (state & GDK_CONTROL_MASK) {
- p = snap_vector_midpoint (p, low_lim, high_lim, snap_fraction);
+ Geom::LineSegment ls(low_lim, high_lim);
+ p = ls.pointAt(round(ls.nearestPoint(p) / snap_fraction) * snap_fraction);
} else {
- p = snap_vector_midpoint (p, low_lim, high_lim, 0);
+ Geom::LineSegment ls(low_lim, high_lim);
+ p = ls.pointAt(ls.nearestPoint(p));
if (!(state & GDK_SHIFT_MASK)) {
Inkscape::Snapper::SnapConstraint cl(low_lim, high_lim - low_lim);
SPDesktop *desktop = dragger->parent->desktop;
@@ -1788,15 +1793,15 @@ GrDrag::updateLevels ()
for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) {
SPItem *item = SP_ITEM(i->data);
- Geom::OptRect rect = item->getBboxDesktop ();
+ Geom::OptRect rect = item->desktopVisualBounds();
if (rect) {
// Remember the edges of the bbox and the center axis
hor_levels.push_back(rect->min()[Geom::Y]);
hor_levels.push_back(rect->max()[Geom::Y]);
- hor_levels.push_back(0.5 * (rect->min()[Geom::Y] + rect->max()[Geom::Y]));
+ hor_levels.push_back(rect->midpoint()[Geom::Y]);
vert_levels.push_back(rect->min()[Geom::X]);
vert_levels.push_back(rect->max()[Geom::X]);
- vert_levels.push_back(0.5 * (rect->min()[Geom::X] + rect->max()[Geom::X]));
+ vert_levels.push_back(rect->midpoint()[Geom::X]);
}
}
}
@@ -1885,8 +1890,8 @@ GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial)
GSList *moving = NULL;
gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, &moving);
- Geom::Point p(x, y);
- p = snap_vector_midpoint (dragger->point + p, low_lim, high_lim, 0);
+ Geom::LineSegment ls(low_lim, high_lim);
+ Geom::Point p = ls.pointAt(ls.nearestPoint(dragger->point + p));
Geom::Point displacement = p - dragger->point;
for (GSList const* i = moving; i != NULL; i = i->next) {
diff --git a/src/gradient-drag.h b/src/gradient-drag.h
index 40ab065ca..4ad9a1e16 100644
--- a/src/gradient-drag.h
+++ b/src/gradient-drag.h
@@ -20,7 +20,6 @@
#include <vector>
#include <forward.h>
-#include <libnr/nr-forward.h>
#include <2geom/point.h>
#include <knot-enums.h>
diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp
index 57002bfb6..6197be9f7 100644
--- a/src/graphlayout.cpp
+++ b/src/graphlayout.cpp
@@ -128,7 +128,7 @@ void graphlayout(GSList const *const items) {
++i)
{
SPItem *u=*i;
- Geom::OptRect const item_box(u->getBboxDesktop());
+ Geom::OptRect const item_box = u->desktopVisualBounds();
if(item_box) {
Geom::Point ll(item_box->min());
Geom::Point ur(item_box->max());
@@ -231,8 +231,8 @@ void graphlayout(GSList const *const items) {
map<string,unsigned>::iterator i=nodelookup.find(u->getId());
if(i!=nodelookup.end()) {
Rectangle* r=rs[i->second];
- Geom::OptRect item_box(u->getBboxDesktop());
- if(item_box) {
+ Geom::OptRect item_box = u->desktopVisualBounds();
+ if (item_box) {
Geom::Point const curr(item_box->midpoint());
Geom::Point const dest(r->getCentreX(),r->getCentreY());
sp_item_move_rel(u, Geom::Translate(dest - curr));
diff --git a/src/helper/action.cpp b/src/helper/action.cpp
index 84d150615..3eb881300 100644
--- a/src/helper/action.cpp
+++ b/src/helper/action.cpp
@@ -1,5 +1,3 @@
-#define __SP_ACTION_C__
-
/** \file
* SPAction implementation
*
@@ -23,26 +21,31 @@
static void sp_action_class_init (SPActionClass *klass);
static void sp_action_init (SPAction *action);
-static void sp_action_finalize (NRObject *object);
+static void sp_action_finalize (GObject *object);
-static NRActiveObjectClass *parent_class;
+static GObjectClass *parent_class;
/**
* Register SPAction class and return its type.
*/
-NRType
+GType
sp_action_get_type (void)
{
- static unsigned int type = 0;
- if (!type) {
- type = nr_object_register_type (NR_TYPE_ACTIVE_OBJECT,
- "SPAction",
- sizeof (SPActionClass),
- sizeof (SPAction),
- (void (*) (NRObjectClass *)) sp_action_class_init,
- (void (*) (NRObject *)) sp_action_init);
- }
- return type;
+ static GType type = 0;
+ if (!type) {
+ GTypeInfo info = {
+ sizeof(SPActionClass),
+ NULL, NULL,
+ (GClassInitFunc) sp_action_class_init,
+ NULL, NULL,
+ sizeof(SPAction),
+ 0,
+ (GInstanceInitFunc) sp_action_init,
+ NULL
+ };
+ type = g_type_register_static(G_TYPE_OBJECT, "SPAction", &info, (GTypeFlags)0);
+ }
+ return type;
}
/**
@@ -51,14 +54,10 @@ sp_action_get_type (void)
static void
sp_action_class_init (SPActionClass *klass)
{
- NRObjectClass * object_class;
-
- object_class = (NRObjectClass *) klass;
+ parent_class = (GObjectClass*) g_type_class_ref(G_TYPE_OBJECT);
- parent_class = (NRActiveObjectClass *) (((NRObjectClass *) klass)->parent);
-
- object_class->finalize = sp_action_finalize;
- object_class->cpp_ctor = NRObject::invoke_ctor<SPAction>;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ object_class->finalize = sp_action_finalize;
}
/**
@@ -72,24 +71,32 @@ sp_action_init (SPAction *action)
action->view = NULL;
action->id = action->name = action->tip = NULL;
action->image = NULL;
+
+ new (&action->signal_perform) sigc::signal<void>();
+ new (&action->signal_set_sensitive) sigc::signal<void, bool>();
+ new (&action->signal_set_active) sigc::signal<void, bool>();
+ new (&action->signal_set_name) sigc::signal<void, Glib::ustring const &>();
}
/**
* Called before SPAction object destruction.
*/
static void
-sp_action_finalize (NRObject *object)
+sp_action_finalize (GObject *object)
{
- SPAction *action;
+ SPAction *action = SP_ACTION(object);
- action = (SPAction *) object;
+ g_free (action->image);
+ g_free (action->tip);
+ g_free (action->name);
+ g_free (action->id);
- if (action->image) free (action->image);
- if (action->tip) free (action->tip);
- if (action->name) free (action->name);
- if (action->id) free (action->id);
+ action->signal_perform.~signal();
+ action->signal_set_sensitive.~signal();
+ action->signal_set_active.~signal();
+ action->signal_set_name.~signal();
- ((NRObjectClass *) (parent_class))->finalize (object);
+ parent_class->finalize (object);
}
/**
@@ -103,14 +110,14 @@ sp_action_new(Inkscape::UI::View::View *view,
const gchar *image,
Inkscape::Verb * verb)
{
- SPAction *action = (SPAction *)nr_object_new(SP_TYPE_ACTION);
+ SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL);
action->view = view;
action->sensitive = TRUE;
- if (id) action->id = strdup (id);
- if (name) action->name = strdup (name);
- if (tip) action->tip = strdup (tip);
- if (image) action->image = strdup (image);
+ action->id = g_strdup (id);
+ action->name = g_strdup (name);
+ action->tip = g_strdup (tip);
+ action->image = g_strdup (image);
action->verb = verb;
return action;
@@ -147,41 +154,16 @@ public:
\return None
\brief Executes an action
\param action The action to be executed
- \param data Data that is passed into the action. This depends
- on the situation that the action is used in.
-
- This function implements the 'action' in SPActions. It first validates
- its parameters, making sure it got an action passed in. Then it
- turns that action into its parent class of NRActiveObject. The
- NRActiveObject allows for listeners to be attached to it. This
- function goes through those listeners and calls them with the
- vector that was attached to the listener.
+ \param data ignored
*/
void
sp_action_perform (SPAction *action, void * data)
{
- NRActiveObject *aobject;
-
- nr_return_if_fail (action != NULL);
- nr_return_if_fail (SP_IS_ACTION (action));
+ g_return_if_fail (action != NULL);
+ g_return_if_fail (SP_IS_ACTION (action));
Inkscape::Debug::EventTracker<ActionEvent> tracker(action);
-
- aobject = NR_ACTIVE_OBJECT(action);
- if (aobject->callbacks) {
- unsigned int i;
- for (i = 0; i < aobject->callbacks->length; i++) {
- NRObjectListener *listener;
- SPActionEventVector *avector;
-
- listener = &aobject->callbacks->listeners[i];
- avector = (SPActionEventVector *) listener->vector;
-
- if ((listener->size >= sizeof (SPActionEventVector)) && avector != NULL && avector->perform != NULL) {
- avector->perform (action, listener->data, data);
- }
- }
- }
+ action->signal_perform.emit();
}
/**
@@ -190,26 +172,10 @@ sp_action_perform (SPAction *action, void * data)
void
sp_action_set_active (SPAction *action, unsigned int active)
{
- nr_return_if_fail (action != NULL);
- nr_return_if_fail (SP_IS_ACTION (action));
+ g_return_if_fail (action != NULL);
+ g_return_if_fail (SP_IS_ACTION (action));
- if (active != action->active) {
- NRActiveObject *aobject;
- action->active = active;
- aobject = (NRActiveObject *) action;
- if (aobject->callbacks) {
- unsigned int i;
- for (i = 0; i < aobject->callbacks->length; i++) {
- NRObjectListener *listener;
- SPActionEventVector *avector;
- listener = aobject->callbacks->listeners + i;
- avector = (SPActionEventVector *) listener->vector;
- if ((listener->size >= sizeof (SPActionEventVector)) && avector->set_active) {
- avector->set_active (action, active, listener->data);
- }
- }
- }
- }
+ action->signal_set_active.emit(active);
}
/**
@@ -218,59 +184,20 @@ sp_action_set_active (SPAction *action, unsigned int active)
void
sp_action_set_sensitive (SPAction *action, unsigned int sensitive)
{
- nr_return_if_fail (action != NULL);
- nr_return_if_fail (SP_IS_ACTION (action));
+ g_return_if_fail (action != NULL);
+ g_return_if_fail (SP_IS_ACTION (action));
- if (sensitive != action->sensitive) {
- NRActiveObject *aobject;
- action->sensitive = sensitive;
- aobject = (NRActiveObject *) action;
- if (aobject->callbacks) {
- unsigned int i;
- for (i = 0; i < aobject->callbacks->length; i++) {
- NRObjectListener *listener;
- SPActionEventVector *avector;
- listener = aobject->callbacks->listeners + i;
- avector = (SPActionEventVector *) listener->vector;
- if ((listener->size >= sizeof (SPActionEventVector)) && avector->set_sensitive) {
- avector->set_sensitive (action, sensitive, listener->data);
- }
- }
- }
- }
+ action->signal_set_sensitive.emit(sensitive);
}
-
-/**
- * Change name for all actions that can be taken with the action.
- */
void
-sp_action_set_name (SPAction *action, Glib::ustring name)
+sp_action_set_name (SPAction *action, Glib::ustring const &name)
{
- nr_return_if_fail (action != NULL);
- nr_return_if_fail (SP_IS_ACTION (action));
-
- NRActiveObject *aobject;
- g_free(action->name);
- action->name = g_strdup(name.c_str());
- aobject = (NRActiveObject *) action;
- if (aobject->callbacks) {
- unsigned int i;
- for (i = 0; i < aobject->callbacks->length; i++) {
- NRObjectListener *listener;
- SPActionEventVector *avector;
- listener = aobject->callbacks->listeners + i;
- avector = (SPActionEventVector *) listener->vector;
- if ((listener->size >= sizeof (SPActionEventVector)) && avector->set_name) {
- avector->set_name (action, name, listener->data);
- }
- }
- }
+ g_free(action->name);
+ action->name = g_strdup(name.data());
+ action->signal_set_name.emit(name);
}
-
-
-
/**
* Return View associated with the action.
*/
diff --git a/src/helper/action.h b/src/helper/action.h
index 14a91b453..7e4da3312 100644
--- a/src/helper/action.h
+++ b/src/helper/action.h
@@ -1,11 +1,6 @@
-#ifndef __SP_ACTION_H__
-#define __SP_ACTION_H__
-
/** \file
* Inkscape UI action implementation
- */
-
-/*
+ *//*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
*
@@ -14,41 +9,27 @@
* This code is in public domain
*/
-/** A macro to get the GType for actions */
-#define SP_TYPE_ACTION (sp_action_get_type())
-/** A macro to cast and check the cast of changing an object to an action */
-#define SP_ACTION(o) (NR_CHECK_INSTANCE_CAST((o), SP_TYPE_ACTION, SPAction))
-/** A macro to check whether or not something is an action */
-#define SP_IS_ACTION(o) (NR_CHECK_INSTANCE_TYPE((o), SP_TYPE_ACTION))
+#ifndef SEEN_INKSCAPE_SP_ACTION_H
+#define SEEN_INKSCAPE_SP_ACTION_H
+#include <sigc++/sigc++.h>
+#include <glibmm/ustring.h>
#include "helper/helper-forward.h"
-#include "libnr/nr-object.h"
#include "forward.h"
-#include <glibmm/ustring.h>
-//class Inkscape::UI::View::View;
+#define SP_TYPE_ACTION (sp_action_get_type())
+#define SP_ACTION(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ACTION, SPAction))
+#define SP_ACTION_CLASS(o) (G_TYPE_CHECK_CLASS_CAST((o), SP_TYPE_ACTION, SPActionClass))
+#define SP_IS_ACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ACTION))
namespace Inkscape {
class Verb;
}
-
-/** This is a structure that is used to hold all the possible
- actions that can be taken with an action. These are the
- function pointers available. */
-struct SPActionEventVector {
- NRObjectEventVector object_vector; /**< Parent class */
- void (* perform)(SPAction *action, void *ldata, void *pdata); /**< Actually do the action of the event. Called by sp_perform_action */
- void (* set_active)(SPAction *action, unsigned active, void *data); /**< Callback for activation change */
- void (* set_sensitive)(SPAction *action, unsigned sensitive, void *data); /**< Callback for a change in sensitivity */
- void (* set_shortcut)(SPAction *action, unsigned shortcut, void *data); /**< Callback for setting the shortcut for this function */
- void (* set_name)(SPAction *action, Glib::ustring, void *data); /**< Callback for setting the name for this function */
-};
-
/** All the data that is required to be an action. This
structure identifies the action and has the data to
create menus and toolbars for the action */
-struct SPAction : public NRActiveObject {
+struct SPAction : public GObject {
unsigned sensitive : 1; /**< Value to track whether the action is sensitive */
unsigned active : 1; /**< Value to track whether the action is active */
Inkscape::UI::View::View *view; /**< The View to which this action is attached */
@@ -57,14 +38,19 @@ struct SPAction : public NRActiveObject {
gchar *tip; /**< A tooltip to describe the action */
gchar *image; /**< An image to visually identify the action */
Inkscape::Verb *verb; /**< The verb that produced this action */
+
+ sigc::signal<void> signal_perform;
+ sigc::signal<void, bool> signal_set_sensitive;
+ sigc::signal<void, bool> signal_set_active;
+ sigc::signal<void, Glib::ustring const &> signal_set_name;
};
/** The action class is the same as its parent. */
struct SPActionClass {
- NRActiveObjectClass parent_class; /**< Parent Class */
+ GObjectClass parent_class; /**< Parent Class */
};
-NRType sp_action_get_type();
+GType sp_action_get_type();
SPAction *sp_action_new(Inkscape::UI::View::View *view,
gchar const *id,
@@ -76,12 +62,11 @@ SPAction *sp_action_new(Inkscape::UI::View::View *view,
void sp_action_perform(SPAction *action, void *data);
void sp_action_set_active(SPAction *action, unsigned active);
void sp_action_set_sensitive(SPAction *action, unsigned sensitive);
-void sp_action_set_name (SPAction *action, Glib::ustring);
+void sp_action_set_name(SPAction *action, Glib::ustring const &name);
Inkscape::UI::View::View *sp_action_get_view(SPAction *action);
#endif
-
/*
Local Variables:
mode:c++
diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp
index fdfbdb9d3..61551ad2e 100644
--- a/src/helper/geom.cpp
+++ b/src/helper/geom.cpp
@@ -22,7 +22,6 @@
#include <2geom/rect.h>
#include <2geom/coord.h>
#include <2geom/sbasis-to-bezier.h>
-#include <libnr/nr-convert2geom.h>
#include <glibmm.h>
using Geom::X;
diff --git a/src/inkview.cpp b/src/inkview.cpp
index 09169f5be..0b1292e8e 100644
--- a/src/inkview.cpp
+++ b/src/inkview.cpp
@@ -39,7 +39,6 @@
#include <locale.h>
#include <glib/gmem.h>
-#include <libnr/nr-macros.h>
// #include <stropts.h>
diff --git a/src/interface.cpp b/src/interface.cpp
index a981424fa..8cb9698b7 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -125,25 +125,12 @@ static void sp_ui_drag_leave( GtkWidget *widget,
GdkDragContext *drag_context,
guint event_time,
gpointer user_data );
-static void sp_ui_menu_item_set_sensitive(SPAction *action,
- unsigned int sensitive,
- void *data);
-static void sp_ui_menu_item_set_name(SPAction *action,
- Glib::ustring name,
- void *data);
+static void sp_ui_menu_item_set_name(GtkWidget *data,
+ Glib::ustring const &name);
static void sp_recent_open(GtkRecentChooser *, gpointer);
static void injectRenamedIcons();
-SPActionEventVector menu_item_event_vector = {
- {NULL},
- NULL,
- NULL, /* set_active */
- sp_ui_menu_item_set_sensitive, /* set_sensitive */
- NULL, /* set_shortcut */
- sp_ui_menu_item_set_name /* set_name */
-};
-
static const int MIN_ONSCREEN_DISTANCE = 50;
void
@@ -508,7 +495,6 @@ sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::
unsigned int shortcut;
action = verb->get_action(view);
-
if (!action) return NULL;
shortcut = sp_shortcut_get_primary(verb);
@@ -542,7 +528,15 @@ sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::
gtk_container_add((GtkContainer *) item, name_lbl);
}
- nr_active_object_add_listener((NRActiveObject *)action, (NRObjectEventVector *)&menu_item_event_vector, sizeof(SPActionEventVector), item);
+ action->signal_set_sensitive.connect(
+ sigc::bind<0>(
+ sigc::ptr_fun(&gtk_widget_set_sensitive),
+ item));
+ action->signal_set_name.connect(
+ sigc::bind<0>(
+ sigc::ptr_fun(&sp_ui_menu_item_set_name),
+ item));
+
if (!action->sensitive) {
gtk_widget_set_sensitive(item, FALSE);
}
@@ -716,7 +710,6 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *
gtk_container_add((GtkContainer *) item, l);
}
#if 0
- nr_active_object_add_listener((NRActiveObject *)action, (NRObjectEventVector *)&menu_item_event_vector, sizeof(SPActionEventVector), item);
if (!action->sensitive) {
gtk_widget_set_sensitive(item, FALSE);
}
@@ -1425,7 +1418,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
// move to mouse pointer
{
sp_desktop_document(desktop)->ensureUpToDate();
- Geom::OptRect sel_bbox = selection->bounds();
+ Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
sp_selection_move_relative(selection, m, false);
@@ -1587,13 +1580,7 @@ sp_ui_overwrite_file(gchar const *filename)
}
static void
-sp_ui_menu_item_set_sensitive(SPAction */*action*/, unsigned int sensitive, void *data)
-{
- return gtk_widget_set_sensitive(GTK_WIDGET(data), sensitive);
-}
-
-static void
-sp_ui_menu_item_set_name(SPAction */*action*/, Glib::ustring name, void *data)
+sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name)
{
void *child = GTK_BIN (data)->child;
//child is either
diff --git a/src/knotholder.h b/src/knotholder.h
index 76142ed98..0dd3bba1e 100644
--- a/src/knotholder.h
+++ b/src/knotholder.h
@@ -20,7 +20,6 @@
#include <glib/gtypes.h>
#include "knot-enums.h"
#include "forward.h"
-#include "libnr/nr-forward.h"
#include <2geom/forward.h>
#include "knot-holder-entity.h"
#include <list>
diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt
deleted file mode 100644
index 8a31e20db..000000000
--- a/src/libnr/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-
-set(nr_SRC
- # in-svg-plane-test.cpp
- nr-object.cpp
- nr-point-fns.cpp
- # nr-point-fns-test.cpp
- nr-rect.cpp
- nr-rect-l.cpp
- # nr-rotate-fns-test.cpp
- #nr-translate-test.cpp
- # nr-types-test.cpp
- nr-values.cpp
- # testnr.cpp
-
-
- # -------
- # Headers
- # in-svg-plane-test.h
- in-svg-plane.h
- nr-convert2geom.h
- nr-forward.h
- nr-macros.h
- nr-object.h
- # nr-point-fns-test.h
- nr-point-fns.h
- nr-rect-l.h
- nr-rect.h
- # nr-translate-test.h
- # nr-types-test.h
- nr-values.h
-)
-
-add_inkscape_lib(nr_LIB "${nr_SRC}")
diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert
deleted file mode 100644
index cdb0b482c..000000000
--- a/src/libnr/Makefile_insert
+++ /dev/null
@@ -1,23 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- libnr/in-svg-plane.h \
- libnr/nr-convert2geom.h \
- libnr/nr-forward.h \
- libnr/nr-macros.h \
- libnr/nr-object.cpp \
- libnr/nr-object.h \
- libnr/nr-point-fns.cpp \
- libnr/nr-point-fns.h \
- libnr/nr-rect-l.cpp \
- libnr/nr-rect-l.h \
- libnr/nr-rect.cpp \
- libnr/nr-rect.h \
- libnr/nr-values.cpp \
- libnr/nr-values.h
-
-# ######################
-# ### CxxTest stuff ####
-# ######################
-CXXTEST_TESTSUITES += \
- $(srcdir)/libnr/in-svg-plane-test.h
diff --git a/src/libnr/in-svg-plane-test.h b/src/libnr/in-svg-plane-test.h
deleted file mode 100644
index 696f82421..000000000
--- a/src/libnr/in-svg-plane-test.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <cxxtest/TestSuite.h>
-
-#include <glib/gmacros.h>
-#include <cmath>
-
-#include "libnr/in-svg-plane.h"
-#include <2geom/math-utils.h>
-#include <2geom/point.h>
-
-class InSvgPlaneTest : public CxxTest::TestSuite
-{
-public:
-
- InSvgPlaneTest() :
- setupValid(true),
- p3n4( 3.0, -4.0 ),
- p0(0.0, 0.0),
- small( pow(2.0, -1070) ),
- inf( 1e400 ),
- nan( inf - inf ),
- small_left( -small, 0.0 ),
- small_n3_4( -3.0 * small, 4.0 * small ),
- part_nan( 3., nan )
- {
- setupValid &= IS_NAN(nan);
- setupValid &= !IS_NAN(small);
- }
- virtual ~InSvgPlaneTest() {}
-
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
- static InSvgPlaneTest *createSuite() { return new InSvgPlaneTest(); }
- static void destroySuite( InSvgPlaneTest *suite ) { delete suite; }
-
-// Called before each test in this suite
- void setUp()
- {
- TS_ASSERT( setupValid );
- }
-
- bool setupValid;
- Geom::Point const p3n4;
- Geom::Point const p0;
- double const small;
- double const inf;
- double const nan;
- Geom::Point const small_left;
- Geom::Point const small_n3_4;
- Geom::Point const part_nan;
-
-
- void testInSvgPlane(void)
- {
- TS_ASSERT( in_svg_plane(p3n4) );
- TS_ASSERT( in_svg_plane(p0) );
- TS_ASSERT( in_svg_plane(small_left) );
- TS_ASSERT( in_svg_plane(small_n3_4) );
- TS_ASSERT_DIFFERS( nan, nan );
- TS_ASSERT( !in_svg_plane(Geom::Point(nan, 3.)) );
- TS_ASSERT( !in_svg_plane(Geom::Point(inf, nan)) );
- TS_ASSERT( !in_svg_plane(Geom::Point(0., -inf)) );
- double const xs[] = {inf, -inf, nan, 1., -2., small, -small};
- for (unsigned i = 0; i < G_N_ELEMENTS(xs); ++i) {
- for (unsigned j = 0; j < G_N_ELEMENTS(xs); ++j) {
- TS_ASSERT_EQUALS( in_svg_plane(Geom::Point(xs[i], xs[j])),
- (fabs(xs[i]) < inf &&
- fabs(xs[j]) < inf ) );
- }
- }
- }
-};
-
-/*
- 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/libnr/in-svg-plane.h b/src/libnr/in-svg-plane.h
deleted file mode 100644
index 68c9e92a0..000000000
--- a/src/libnr/in-svg-plane.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef SEEN_LIBNR_IN_SVG_PLANE_H
-#define SEEN_LIBNR_IN_SVG_PLANE_H
-
-#include <2geom/point.h>
-
-/**
- * Returns true iff the coordinates of \a p are finite, non-NaN, and "small enough". Currently we
- * use the magic number 1e18 for determining "small enough", as this number has in the past been
- * used in sodipodi code as a sort of "infinity" value.
- *
- * For SVG Tiny output, we might choose a smaller value corresponding to the range of valid numbers
- * in SVG Tiny (which uses fixed-point arithmetic).
- */
-inline bool
-in_svg_plane(Geom::Point const &p)
-{
- return Geom::LInfty(p) < 1e18;
-}
-
-
-#endif /* !SEEN_LIBNR_IN_SVG_PLANE_H */
-
-/*
- 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/libnr/makefile.in b/src/libnr/makefile.in
deleted file mode 100644
index 9f8d3919e..000000000
--- a/src/libnr/makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# Convenience stub makefile to call the real Makefile.
-
-@SET_MAKE@
-
-OBJEXT = @OBJEXT@
-
-# Explicit so that it's the default rule.
-all:
- cd .. && $(MAKE) libnr/all
-
-clean %.a %.$(OBJEXT):
- cd .. && $(MAKE) libnr/$@
-
-.PHONY: all clean
-
-.SUFFIXES:
-.SUFFIXES: .a .$(OBJEXT)
diff --git a/src/libnr/nr-convert2geom.h b/src/libnr/nr-convert2geom.h
deleted file mode 100644
index 7e2423ea6..000000000
--- a/src/libnr/nr-convert2geom.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef INKSCAPE_LIBNR_CONVERT2GEOM_H
-#define INKSCAPE_LIBNR_CONVERT2GEOM_H
-
-/*
- * Converts between NR and 2Geom types.
- *
-* Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <libnr/nr-rect.h>
-#include <2geom/rect.h>
-
-inline Geom::OptRect to_2geom(NRRect const *nr) {
- Geom::OptRect ret;
- if (!nr) return ret;
- if (nr->x1 < nr->x0 || nr->y1 < nr->y0) return ret;
- ret = Geom::Rect(Geom::Point(nr->x0, nr->y0), Geom::Point(nr->x1, nr->y1));
- return ret;
-}
-
-#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/libnr/nr-forward.h b/src/libnr/nr-forward.h
deleted file mode 100644
index 4895ad407..000000000
--- a/src/libnr/nr-forward.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __NR_FORWARD_H__
-#define __NR_FORWARD_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-struct NRPixBlock;
-struct NRRect;
-struct NRRectL;
-
-#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/libnr/nr-macros.h b/src/libnr/nr-macros.h
deleted file mode 100644
index 37a3675e6..000000000
--- a/src/libnr/nr-macros.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef __NR_MACROS_H__
-#define __NR_MACROS_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <math.h>
-
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <assert.h>
-
-#ifndef TRUE
-#define TRUE (!0)
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef MAX
-#define MAX(a,b) (((a) < (b)) ? (b) : (a))
-#endif
-#ifndef MIN
-#define MIN(a,b) (((a) > (b)) ? (b) : (a))
-#endif
-
-/** Returns v bounded to within [a, b]. If v is NaN then returns a.
- *
- * \pre \a a \<= \a b.
- */
-#define NR_CLAMP(v,a,b) \
- (assert (a <= b), \
- ((v) >= (a)) \
- ? (((v) > (b)) \
- ? (b) \
- : (v)) \
- : (a))
-
-#undef CLAMP /* get rid of glib's version, which doesn't handle NaN correctly */
-#define CLAMP(v,a,b) NR_CLAMP(v,a,b)
-
-#define NR_DF_TEST_CLOSE(a,b,e) (fabs ((a) - (b)) <= (e))
-
-// Todo: move these into nr-matrix.h
-#define NR_RECT_DFLS_TEST_EMPTY(a) (((a)->x0 >= (a)->x1) || ((a)->y0 >= (a)->y1))
-#define NR_RECT_DFLS_TEST_EMPTY_REF(a) (((a).x0 >= (a).x1) || ((a).y0 >= (a).y1))
-#define NR_RECT_DFLS_TEST_INTERSECT(a,b) (((a)->x0 < (b)->x1) && ((a)->x1 > (b)->x0) && ((a)->y0 < (b)->y1) && ((a)->y1 > (b)->y0))
-#define NR_RECT_DFLS_TEST_INTERSECT_REF(a,b) (((a).x0 < (b).x1) && ((a).x1 > (b).x0) && ((a).y0 < (b).y1) && ((a).y1 > (b).y0))
-#define NR_RECT_DF_POINT_DF_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1))
-#define NR_RECT_LS_POINT_LS_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1))
-#define NR_RECT_LS_TEST_INSIDE(r,x,y) ((x >= (r)->x0) && (x < (r)->x1) && (y >= (r)->y0) && (y < (r)->y1))
-
-#define NR_MATRIX_D_FROM_DOUBLE(d) ((NR::Matrix *) &(d)[0])
-
-#endif
diff --git a/src/libnr/nr-object.cpp b/src/libnr/nr-object.cpp
deleted file mode 100644
index d92052d10..000000000
--- a/src/libnr/nr-object.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-#define __NR_OBJECT_C__
-
-/*
- * RGBA display list system for inkscape
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * MenTaLguY <mental@rydia.net>
- *
- * This code is in public domain
- */
-
-#include <string.h>
-#include <stdio.h>
-
-#include <typeinfo>
-
-#include <glib/gmem.h>
-#include <libnr/nr-macros.h>
-
-#include "nr-object.h"
-#include "debug/event-tracker.h"
-#include "debug/simple-event.h"
-#include "util/share.h"
-#include "util/format.h"
-
-unsigned int nr_emit_fail_warning(const gchar *file, unsigned int line, const gchar *method, const gchar *expr)
-{
- fprintf (stderr, "File %s line %d (%s): Assertion %s failed\n", file, line, method, expr);
- return 1;
-}
-
-/* NRObject */
-
-static NRObjectClass **classes = NULL;
-static unsigned int classes_len = 0;
-static unsigned int classes_size = 0;
-
-NRType nr_type_is_a(NRType type, NRType test)
-{
- nr_return_val_if_fail(type < classes_len, FALSE);
- nr_return_val_if_fail(test < classes_len, FALSE);
-
- NRObjectClass *c = classes[type];
-
- while (c) {
- if (c->type == test) {
- return TRUE;
- }
- c = c->parent;
- }
-
- return FALSE;
-}
-
-void const *nr_object_check_instance_cast(void const *ip, NRType tc)
-{
- nr_return_val_if_fail(ip != NULL, NULL);
- nr_return_val_if_fail(nr_type_is_a(((NRObject const *) ip)->klass->type, tc), ip);
- return ip;
-}
-
-unsigned int nr_object_check_instance_type(void const *ip, NRType tc)
-{
- if (ip == NULL) {
- return FALSE;
- }
-
- return nr_type_is_a(((NRObject const *) ip)->klass->type, tc);
-}
-
-NRType nr_object_register_type(NRType parent,
- gchar const *name,
- unsigned int csize,
- unsigned int isize,
- void (* cinit) (NRObjectClass *),
- void (* iinit) (NRObject *))
-{
- if (classes_len >= classes_size) {
- classes_size += 32;
- classes = g_renew (NRObjectClass *, classes, classes_size);
- if (classes_len == 0) {
- classes[0] = NULL;
- classes_len = 1;
- }
- }
-
- NRType const type = classes_len;
- classes_len += 1;
-
- classes[type] = (NRObjectClass*) new char[csize];
- NRObjectClass *c = classes[type];
-
- /* FIXME: is this necessary? */
- memset(c, 0, csize);
-
- if (classes[parent]) {
- memcpy(c, classes[parent], classes[parent]->csize);
- }
-
- c->type = type;
- c->parent = classes[parent];
- c->name = strdup(name);
- c->csize = csize;
- c->isize = isize;
- c->cinit = cinit;
- c->iinit = iinit;
-
- c->cinit(c);
-
- return type;
-}
-
-static void nr_object_class_init (NRObjectClass *klass);
-static void nr_object_init (NRObject *object);
-static void nr_object_finalize (NRObject *object);
-
-NRType nr_object_get_type()
-{
- static NRType type = 0;
-
- if (!type) {
- type = nr_object_register_type (0,
- "NRObject",
- sizeof (NRObjectClass),
- sizeof (NRObject),
- (void (*) (NRObjectClass *)) nr_object_class_init,
- (void (*) (NRObject *)) nr_object_init);
- }
-
- return type;
-}
-
-static void nr_object_class_init(NRObjectClass *c)
-{
- c->finalize = nr_object_finalize;
- c->cpp_ctor = NRObject::invoke_ctor<NRObject>;
-}
-
-static void nr_object_init (NRObject */*object*/)
-{
-}
-
-static void nr_object_finalize (NRObject */*object*/)
-{
-}
-
-/* Dynamic lifecycle */
-
-static void nr_class_tree_object_invoke_init(NRObjectClass *c, NRObject *object)
-{
- if (c->parent) {
- nr_class_tree_object_invoke_init(c->parent, object);
- }
- c->iinit (object);
-}
-
-namespace {
-
-namespace Debug = Inkscape::Debug;
-namespace Util = Inkscape::Util;
-
-typedef Debug::SimpleEvent<Debug::Event::FINALIZERS> BaseFinalizerEvent;
-
-class FinalizerEvent : public BaseFinalizerEvent {
-public:
- FinalizerEvent(NRObject *object)
- : BaseFinalizerEvent(Util::share_static_string("nr-object-finalizer"))
- {
- _addProperty("object", Util::format("%p", object));
- _addProperty("class", Util::share_static_string(typeid(*object).name()));
- }
-};
-
-void finalize_object(void *base, void *)
-{
- NRObject *object = reinterpret_cast<NRObject *>(base);
- Debug::EventTracker<FinalizerEvent> tracker(object);
- object->klass->finalize(object);
- object->~NRObject();
-}
-
-}
-
-NRObject *NRObject::alloc(NRType type)
-{
- nr_return_val_if_fail (type < classes_len, NULL);
-
- NRObjectClass *c = classes[type];
-
- if ( c->parent && c->cpp_ctor == c->parent->cpp_ctor ) {
- g_error("Cannot instantiate NRObject class %s which has not registered a C++ constructor\n", c->name);
- }
-
- NRObject *object = reinterpret_cast<NRObject *>(
- ::operator new(c->isize, Inkscape::GC::SCANNED, Inkscape::GC::AUTO,
- &finalize_object, NULL)
- );
- memset(object, 0xf0, c->isize);
-
- c->cpp_ctor(object);
- object->klass = c;
- nr_class_tree_object_invoke_init (c, object);
-
- return object;
-}
-
-/* NRActiveObject */
-
-static void nr_active_object_class_init(NRActiveObjectClass *c);
-static void nr_active_object_init(NRActiveObject *object);
-static void nr_active_object_finalize(NRObject *object);
-
-static NRObjectClass *parent_class;
-
-NRType nr_active_object_get_type()
-{
- static NRType type = 0;
- if (!type) {
- type = nr_object_register_type (NR_TYPE_OBJECT,
- "NRActiveObject",
- sizeof (NRActiveObjectClass),
- sizeof (NRActiveObject),
- (void (*) (NRObjectClass *)) nr_active_object_class_init,
- (void (*) (NRObject *)) nr_active_object_init);
- }
- return type;
-}
-
-static void nr_active_object_class_init(NRActiveObjectClass *c)
-{
- NRObjectClass *object_class = (NRObjectClass *) c;
-
- parent_class = object_class->parent;
-
- object_class->finalize = nr_active_object_finalize;
- object_class->cpp_ctor = NRObject::invoke_ctor<NRActiveObject>;
-}
-
-static void nr_active_object_init(NRActiveObject */*object*/)
-{
-}
-
-static void nr_active_object_finalize(NRObject *object)
-{
- NRActiveObject *aobject = (NRActiveObject *) object;
-
- if (aobject->callbacks) {
- for (unsigned int i = 0; i < aobject->callbacks->length; i++) {
- NRObjectListener *listener = aobject->callbacks->listeners + i;
- if ( listener->vector->dispose ) {
- listener->vector->dispose(object, listener->data);
- }
- }
- g_free (aobject->callbacks);
- }
-
- ((NRObjectClass *) (parent_class))->finalize(object);
-}
-
-void nr_active_object_add_listener(NRActiveObject *object,
- const NRObjectEventVector *vector,
- unsigned int size,
- void *data)
-{
- if (!object->callbacks) {
- object->callbacks = (NRObjectCallbackBlock*)g_malloc(sizeof(NRObjectCallbackBlock));
- object->callbacks->size = 1;
- object->callbacks->length = 0;
- }
-
- if (object->callbacks->length >= object->callbacks->size) {
- int newsize = object->callbacks->size << 1;
- object->callbacks = (NRObjectCallbackBlock *)
- g_realloc(object->callbacks, sizeof(NRObjectCallbackBlock) + (newsize - 1) * sizeof (NRObjectListener));
- object->callbacks->size = newsize;
- }
-
- NRObjectListener *listener = object->callbacks->listeners + object->callbacks->length;
- listener->vector = vector;
- listener->size = size;
- listener->data = data;
- object->callbacks->length += 1;
-}
-
-void nr_active_object_remove_listener_by_data(NRActiveObject *object, void *data)
-{
- if (object->callbacks == NULL) {
- return;
- }
-
- for (unsigned i = 0; i < object->callbacks->length; i++) {
- NRObjectListener *listener = object->callbacks->listeners + i;
- if ( listener->data == data ) {
- object->callbacks->length -= 1;
- if ( object->callbacks->length < 1 ) {
- g_free(object->callbacks);
- object->callbacks = NULL;
- } else if ( object->callbacks->length != i ) {
- *listener = object->callbacks->listeners[object->callbacks->length];
- }
- return;
- }
- }
-}
-
-
-
-/*
- 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 :
diff --git a/src/libnr/nr-object.h b/src/libnr/nr-object.h
deleted file mode 100644
index 269130284..000000000
--- a/src/libnr/nr-object.h
+++ /dev/null
@@ -1,157 +0,0 @@
-#ifndef __NR_OBJECT_H__
-#define __NR_OBJECT_H__
-
-/*
- * RGBA display list system for inkscape
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * MenTaLguY <mental@rydia.net>
- *
- * This code is in public domain
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib/gtypes.h>
-#include "gc-managed.h"
-#include "gc-finalized.h"
-#include "gc-anchored.h"
-
-typedef guint32 NRType;
-
-struct NRObject;
-struct NRObjectClass;
-
-#define NR_TYPE_OBJECT (nr_object_get_type ())
-#define NR_OBJECT(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_OBJECT, NRObject))
-#define NR_IS_OBJECT(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_OBJECT))
-
-#define NR_TYPE_ACTIVE_OBJECT (nr_active_object_get_type ())
-#define NR_ACTIVE_OBJECT(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ACTIVE_OBJECT, NRActiveObject))
-#define NR_IS_ACTIVE_OBJECT(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ACTIVE_OBJECT))
-
-#define nr_return_if_fail(expr) if (!(expr) && nr_emit_fail_warning (__FILE__, __LINE__, "?", #expr)) return
-#define nr_return_val_if_fail(expr,val) if (!(expr) && nr_emit_fail_warning (__FILE__, __LINE__, "?", #expr)) return (val)
-
-unsigned int nr_emit_fail_warning (const gchar *file, unsigned int line, const gchar *method, const gchar *expr);
-
-#ifndef NR_DISABLE_CAST_CHECKS
-#define NR_CHECK_INSTANCE_CAST(ip, tc, ct) ((ct *) nr_object_check_instance_cast (ip, tc))
-#else
-#define NR_CHECK_INSTANCE_CAST(ip, tc, ct) ((ct *) ip)
-#endif
-
-#define NR_CHECK_INSTANCE_TYPE(ip, tc) nr_object_check_instance_type (ip, tc)
-#define NR_OBJECT_GET_CLASS(ip) (((NRObject *) ip)->klass)
-
-NRType nr_type_is_a (NRType type, NRType test);
-
-void const *nr_object_check_instance_cast(void const *ip, NRType tc);
-unsigned int nr_object_check_instance_type(void const *ip, NRType tc);
-
-NRType nr_object_register_type (NRType parent,
- gchar const *name,
- unsigned int csize,
- unsigned int isize,
- void (* cinit) (NRObjectClass *),
- void (* iinit) (NRObject *));
-
-/* NRObject */
-
-class NRObject : public Inkscape::GC::Managed<>,
- public Inkscape::GC::Finalized,
- public Inkscape::GC::Anchored
-{
-public:
- NRObjectClass *klass;
-
- static NRObject *alloc(NRType type);
-
- template <typename T>
- static void invoke_ctor(NRObject *object) {
- new (object) T();
- }
-
- /* these can go away eventually */
- NRObject *reference() {
- return Inkscape::GC::anchor(this);
- }
- NRObject *unreference() {
- Inkscape::GC::release(this);
- return NULL;
- }
-
-protected:
- NRObject() {}
-
-private:
- NRObject(NRObject const &); // no copy
- void operator=(NRObject const &); // no assign
-
- void *operator new(size_t size, void *placement) { (void)size; return placement; }
-};
-
-struct NRObjectClass {
- NRType type;
- NRObjectClass *parent;
-
- gchar *name;
- unsigned int csize;
- unsigned int isize;
- void (* cinit) (NRObjectClass *);
- void (* iinit) (NRObject *);
- void (* finalize) (NRObject *object);
- void (*cpp_ctor)(NRObject *object);
-};
-
-NRType nr_object_get_type (void);
-
-/* Dynamic lifecycle */
-
-inline NRObject *nr_object_new (NRType type) {
- return NRObject::alloc(type);
-}
-
-inline NRObject *nr_object_ref (NRObject *object) {
- return object->reference();
-}
-inline NRObject *nr_object_unref (NRObject *object) {
- return object->unreference();
-}
-
-/* NRActiveObject */
-
-struct NRObjectEventVector {
- void (* dispose) (NRObject *object, void *data);
-};
-
-struct NRObjectListener {
- const NRObjectEventVector *vector;
- unsigned int size;
- void *data;
-};
-
-struct NRObjectCallbackBlock {
- unsigned int size;
- unsigned int length;
- NRObjectListener listeners[1];
-};
-
-struct NRActiveObject : public NRObject {
- NRActiveObject() : callbacks(NULL) {}
- NRObjectCallbackBlock *callbacks;
-};
-
-struct NRActiveObjectClass : public NRObjectClass {
-};
-
-NRType nr_active_object_get_type (void);
-
-void nr_active_object_add_listener (NRActiveObject *object, const NRObjectEventVector *vector, unsigned int size, void *data);
-void nr_active_object_remove_listener_by_data (NRActiveObject *object, void *data);
-
-#endif
-
diff --git a/src/libnr/nr-point-fns.cpp b/src/libnr/nr-point-fns.cpp
deleted file mode 100644
index a2e74c112..000000000
--- a/src/libnr/nr-point-fns.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "libnr/nr-point-fns.h"
-
-Geom::Point
-snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end, double snap)
-{
- double length = Geom::distance(begin, end);
- Geom::Point be = (end - begin) / length;
- double r = Geom::dot(p - begin, be);
-
- if (r < 0.0) return begin;
- if (r > length) return end;
-
- double snapdist = length * snap;
- double r_snapped = (snap==0) ? r : floor(r/(snapdist + 0.5)) * snapdist;
-
- return (begin + r_snapped * be);
-}
-
-double
-get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end)
-{
- double length = Geom::distance(begin, end);
- Geom::Point be = (end - begin) / length;
- double r = Geom::dot(p - begin, be);
-
- if (r < 0.0) return 0.0;
- if (r > length) return 1.0;
-
- return (r / length);
-}
-
-Geom::Point
-project_on_linesegment(Geom::Point const &p, Geom::Point const &p1, Geom::Point const &p2)
-{
- // p_proj = projection of p on the linesegment running from p1 to p2
- // p_proj = p1 + u (p2 - p1)
- // calculate u according to "Minimum Distance between a Point and a Line"
- // see http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline/
-
- // Warning: projected points will not necessarily be in between the endpoints of the linesegments!
-
- if (p1 == p2) { // to avoid div. by zero below
- return p;
- }
-
- Geom::Point d1(p-p1); // delta 1
- Geom::Point d2(p2-p1); // delta 2
- double u = Geom::dot(d1, d2) / Geom::L2sq(d2);
-
- return (p1 + u*(p2-p1));
-}
-
-/*
- 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/libnr/nr-point-fns.h b/src/libnr/nr-point-fns.h
deleted file mode 100644
index b26c969aa..000000000
--- a/src/libnr/nr-point-fns.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __NR_POINT_OPS_H__
-#define __NR_POINT_OPS_H__
-
-#include <2geom/point.h>
-
-Geom::Point snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end, double snap);
-
-double get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end);
-
-Geom::Point project_on_linesegment(Geom::Point const &p, Geom::Point const &p1, Geom::Point const &p2);
-
-#endif /* !__NR_POINT_OPS_H__ */
-
-/*
- 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/libnr/nr-rect-l.cpp b/src/libnr/nr-rect-l.cpp
deleted file mode 100644
index 1cb268266..000000000
--- a/src/libnr/nr-rect-l.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "libnr/nr-rect-l.h"
-
-NRRectL::NRRectL()
-{
- x0 = G_MAXINT32;
- y0 = G_MAXINT32;
- x1 = G_MININT32;
- y1 = G_MININT32;
-}
-
-NRRectL::NRRectL(gint32 xmin, gint32 ymin, gint32 xmax, gint32 ymax)
-{
- x0 = xmin;
- y0 = ymin;
- x1 = xmax;
- y1 = ymax;
-}
-
-NRRectL::NRRectL(Geom::OptIntRect const &r)
-{
- if (r) {
- x0 = r->left();
- y0 = r->top();
- x1 = r->right();
- y1 = r->bottom();
- } else {
- x0 = G_MAXINT32;
- y0 = G_MAXINT32;
- x1 = G_MININT32;
- y1 = G_MININT32;
- }
-}
-
-NRRectL::NRRectL(Geom::IntRect const &r)
-{
- x0 = r.left();
- y0 = r.top();
- x1 = r.right();
- y1 = r.bottom();
-}
-
-Geom::OptIntRect NRRectL::upgrade_2geom() const
-{
- Geom::OptIntRect ret;
- if (x0 > x1 || y0 > y1) return ret;
- ret = Geom::IntRect(x0, y0, x1, y1);
- return ret;
-}
-
-/*
- 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/libnr/nr-rect-l.h b/src/libnr/nr-rect-l.h
deleted file mode 100644
index c4c5f5a6d..000000000
--- a/src/libnr/nr-rect-l.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef SEEN_NR_RECT_L_H
-#define SEEN_NR_RECT_L_H
-
-#include <glib.h>
-#include <2geom/int-rect.h>
-
-struct NRRectL {
- gint32 x0, y0, x1, y1;
- NRRectL();
- NRRectL(gint32 xmin, gint32 ymin, gint32 xmax, gint32 ymax);
- explicit NRRectL(Geom::IntRect const &r);
- explicit NRRectL(Geom::OptIntRect const &r);
- operator Geom::OptIntRect() const { Geom::OptIntRect r = upgrade_2geom(); return r; }
- Geom::OptIntRect upgrade_2geom() const;
-};
-
-#endif /* !SEEN_NR_RECT_L_H */
-
-/*
- 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/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp
deleted file mode 100644
index 67857ad49..000000000
--- a/src/libnr/nr-rect.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-#define __NR_RECT_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <algorithm>
-#include "nr-rect.h"
-#include "nr-rect-l.h"
-
-NRRect::NRRect(Geom::OptRect const &rect) {
- if (rect) {
- x0 = rect->min()[Geom::X];
- y0 = rect->min()[Geom::Y];
- x1 = rect->max()[Geom::X];
- y1 = rect->max()[Geom::Y];
- } else {
- *this = NR_RECT_EMPTY;
- }
-}
-
-Geom::OptRect NRRect::upgrade_2geom() const {
- if (x0 > x1 || y0 > y1) {
- return Geom::OptRect();
- } else {
- return Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1));
- }
-}
-
-/**
- * \param r0 Rectangle.
- * \param r1 Another rectangle.
- * \param d Filled in with the intersection of r0 and r1.
- * \return d.
- */
-
-NRRectL *nr_rect_l_intersect(NRRectL *d, const NRRectL *r0, const NRRectL *r1)
-{
- gint32 t;
- t = std::max(r0->x0, r1->x0);
- d->x1 = std::min(r0->x1, r1->x1);
- d->x0 = t;
- t = std::max(r0->y0, r1->y0);
- d->y1 = std::min(r0->y1, r1->y1);
- d->y0 = t;
-
- return d;
-}
-
-NRRect *
-nr_rect_d_intersect (NRRect *d, const NRRect *r0, const NRRect *r1)
-{
- gint32 t;
- t = MAX (r0->x0, r1->x0);
- d->x1 = MIN (r0->x1, r1->x1);
- d->x0 = t;
- t = MAX (r0->y0, r1->y0);
- d->y1 = MIN (r0->y1, r1->y1);
- d->y0 = t;
-
- return d;
-}
-
-// returns minimal rect which covers all of r0 not covered by r1
-NRRectL *
-nr_rect_l_subtract(NRRectL *d, NRRectL const *r0, NRRectL const *r1)
-{
- bool inside1 = nr_rect_l_test_inside(r1, r0->x0, r0->y0);
- bool inside2 = nr_rect_l_test_inside(r1, r0->x1, r0->y0);
- bool inside3 = nr_rect_l_test_inside(r1, r0->x1, r0->y1);
- bool inside4 = nr_rect_l_test_inside(r1, r0->x0, r0->y1);
-
- if (inside1 && inside2 && inside3) {
- *d = NR_RECT_L_EMPTY;
-
- } else if (inside1 && inside2) {
- d->x0 = r0->x0;
- d->y0 = r1->y1;
-
- d->x1 = r0->x1;
- d->y1 = r0->y1;
- } else if (inside2 && inside3) {
- d->x0 = r0->x0;
- d->y0 = r0->y0;
-
- d->x1 = r1->x0;
- d->y1 = r0->y1;
- } else if (inside3 && inside4) {
- d->x0 = r0->x0;
- d->y0 = r0->y0;
-
- d->x1 = r0->x1;
- d->y1 = r1->y0;
- } else if (inside4 && inside1) {
- d->x0 = r1->x1;
- d->y0 = r0->y0;
-
- d->x1 = r0->x1;
- d->y1 = r0->y1;
- } else {
- d->x0 = r0->x0;
- d->y0 = r0->y0;
-
- d->x1 = r0->x1;
- d->y1 = r0->y1;
- }
- return d;
-}
-
-gint32 nr_rect_l_area(NRRectL *r)
-{
- if (!r || NR_RECT_DFLS_TEST_EMPTY (r)) {
- return 0;
- }
- return ((r->x1 - r->x0) * (r->y1 - r->y0));
-}
-
-NRRect *
-nr_rect_d_union (NRRect *d, const NRRect *r0, const NRRect *r1)
-{
- if (NR_RECT_DFLS_TEST_EMPTY (r0)) {
- if (NR_RECT_DFLS_TEST_EMPTY (r1)) {
- *d = NR_RECT_EMPTY;
- } else {
- *d = *r1;
- }
- } else {
- if (NR_RECT_DFLS_TEST_EMPTY (r1)) {
- *d = *r0;
- } else {
- double t;
- t = MIN (r0->x0, r1->x0);
- d->x1 = MAX (r0->x1, r1->x1);
- d->x0 = t;
- t = MIN (r0->y0, r1->y0);
- d->y1 = MAX (r0->y1, r1->y1);
- d->y0 = t;
- }
- }
- return d;
-}
-
-NRRectL *
-nr_rect_l_union (NRRectL *d, const NRRectL *r0, const NRRectL *r1)
-{
- if (NR_RECT_DFLS_TEST_EMPTY (r0)) {
- if (NR_RECT_DFLS_TEST_EMPTY (r1)) {
- *d = NR_RECT_L_EMPTY;
- } else {
- *d = *r1;
- }
- } else {
- if (NR_RECT_DFLS_TEST_EMPTY (r1)) {
- *d = *r0;
- } else {
- double t;
- t = MIN (r0->x0, r1->x0);
- d->x1 = MAX (r0->x1, r1->x1);
- d->x0 = t;
- t = MIN (r0->y0, r1->y0);
- d->y1 = MAX (r0->y1, r1->y1);
- d->y0 = t;
- }
- }
- return d;
-}
-
-NRRect *
-nr_rect_union_pt(NRRect *dst, Geom::Point const &p)
-{
- return nr_rect_d_union_xy(dst, p[Geom::X], p[Geom::Y]);
-}
-
-NRRect *
-nr_rect_d_union_xy (NRRect *d, double x, double y)
-{
- if ((d->x0 <= d->x1) && (d->y0 <= d->y1)) {
- d->x0 = MIN (d->x0, x);
- d->y0 = MIN (d->y0, y);
- d->x1 = MAX (d->x1, x);
- d->y1 = MAX (d->y1, y);
- } else {
- d->x0 = d->x1 = x;
- d->y0 = d->y1 = y;
- }
- return d;
-}
-
-/*
- 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 :
diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h
deleted file mode 100644
index 4931b3e10..000000000
--- a/src/libnr/nr-rect.h
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifndef LIBNR_NR_RECT_H_SEEN
-#define LIBNR_NR_RECT_H_SEEN
-
-/** \file
- * Definitions of NRRect and NR::Rect types, and some associated functions \& macros.
- *//*
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Nathan Hurst <njh@mail.csse.monash.edu.au>
- * MenTaLguY <mental@rydia.net>
- *
- * This code is in public domain
- */
-
-#include <stdexcept>
-#include <limits>
-#include <boost/optional.hpp>
-#include <glib.h>
-#include <2geom/rect.h>
-
-#include "libnr/nr-forward.h"
-#include "libnr/nr-values.h"
-#include "libnr/nr-macros.h"
-
-/* legacy rect stuff */
-/* NULL rect is infinite */
-
-struct NRRect {
- NRRect()
- : x0(0), y0(0), x1(0), y1(0)
- {}
- NRRect(double xmin, double ymin, double xmax, double ymax)
- : x0(xmin), y0(ymin), x1(xmax), y1(ymax)
- {}
- explicit NRRect(Geom::OptRect const &rect);
- operator Geom::OptRect() const { return upgrade_2geom(); }
- Geom::OptRect upgrade_2geom() const;
-
- double x0, y0, x1, y1;
-};
-
-// TODO convert to static overloaded functions (pointer and ref) once performance can be tested:
-#define nr_rect_l_test_empty_ptr(r) ((r) && NR_RECT_DFLS_TEST_EMPTY(r))
-#define nr_rect_l_test_empty(r) NR_RECT_DFLS_TEST_EMPTY_REF(r)
-
-#define nr_rect_d_test_intersect(r0,r1) \
- (!nr_rect_d_test_empty(r0) && !nr_rect_d_test_empty(r1) && \
- !((r0) && (r1) && !NR_RECT_DFLS_TEST_INTERSECT(r0, r1)))
-
-// TODO convert to static overloaded functions (pointer and ref) once performance can be tested:
-#define nr_rect_l_test_intersect_ptr(r0,r1) \
- (!nr_rect_l_test_empty_ptr(r0) && !nr_rect_l_test_empty_ptr(r1) && \
- !((r0) && (r1) && !NR_RECT_DFLS_TEST_INTERSECT(r0, r1)))
-#define nr_rect_l_test_intersect(r0,r1) \
- (!nr_rect_l_test_empty(r0) && !nr_rect_l_test_empty(r1) && \
- !(!NR_RECT_DFLS_TEST_INTERSECT_REF(r0, r1)))
-
-#define nr_rect_d_point_d_test_inside(r,p) ((p) && (!(r) || (!NR_RECT_DF_TEST_EMPTY(r) && NR_RECT_DF_POINT_DF_TEST_INSIDE(r,p))))
-#define nr_rect_l_point_l_test_inside(r,p) ((p) && (!(r) || (!NR_RECT_DFLS_TEST_EMPTY(r) && NR_RECT_LS_POINT_LS_TEST_INSIDE(r,p))))
-#define nr_rect_l_test_inside(r,x,y) ((!(r) || (!NR_RECT_DFLS_TEST_EMPTY(r) && NR_RECT_LS_TEST_INSIDE(r,x,y))))
-
-// returns minimal rect which covers all of r0 not covered by r1
-NRRectL *nr_rect_l_subtract(NRRectL *d, NRRectL const *r0, NRRectL const *r1);
-
-// returns the area of r
-gint32 nr_rect_l_area(NRRectL *r);
-
-/* NULL values are OK for r0 and r1, but not for d */
-NRRect *nr_rect_d_intersect(NRRect *d, NRRect const *r0, NRRect const *r1);
-NRRectL *nr_rect_l_intersect(NRRectL *d, NRRectL const *r0, NRRectL const *r1);
-
-NRRect *nr_rect_d_union(NRRect *d, NRRect const *r0, NRRect const *r1);
-NRRectL *nr_rect_l_union(NRRectL *d, NRRectL const *r0, NRRectL const *r1);
-
-NRRect *nr_rect_union_pt(NRRect *dst, Geom::Point const &p);
-NRRect *nr_rect_d_union_xy(NRRect *d, double x, double y);
-NRRectL *nr_rect_l_union_xy(NRRectL *d, gint32 x, gint32 y);
-
-
-#endif /* !LIBNR_NR_RECT_H_SEEN */
-
-/*
- 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/libnr/nr-values.cpp b/src/libnr/nr-values.cpp
deleted file mode 100644
index 06f33b13f..000000000
--- a/src/libnr/nr-values.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#define __NR_VALUES_C__
-
-#include "libnr/nr-values.h"
-#include "libnr/nr-rect.h"
-#include "libnr/nr-rect-l.h"
-
-/*
-The following predefined objects are for reference
-and comparison.
-*/
-NRRect NR_RECT_EMPTY(NR_HUGE, NR_HUGE, -NR_HUGE, -NR_HUGE);
-NRRectL NR_RECT_L_EMPTY(NR_HUGE_L, NR_HUGE_L, -NR_HUGE_L, -NR_HUGE_L);
-
-/** component_vectors[i] is like $e_i$ in common mathematical usage;
- or equivalently $I_i$ (where $I$ is the identity matrix). */
-Geom::Point const component_vectors[] = {Geom::Point(1., 0.),
- Geom::Point(0., 1.)};
-
diff --git a/src/libnr/nr-values.h b/src/libnr/nr-values.h
deleted file mode 100644
index 07faec9fa..000000000
--- a/src/libnr/nr-values.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef __NR_VALUES_H__
-#define __NR_VALUES_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <libnr/nr-forward.h>
-#include <2geom/point.h>
-
-#define NR_EPSILON 1e-18
-
-#define NR_HUGE 1e18
-#define NR_HUGE_L (0x7fffffff)
-
-/*
-The following predefined objects are for reference
-and comparison. They are defined in nr-values.cpp
-*/
-extern NRRect NR_RECT_EMPTY;
-extern NRRectL NR_RECT_L_EMPTY;
-
-/** component_vectors[i] has 1.0 at position i, and 0.0 elsewhere
- (i.e. in the other position). */
-extern Geom::Point const component_vectors[2];
-
-#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/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp
index 641adc3ac..f8b2c3b9d 100644
--- a/src/libnrtype/FontInstance.cpp
+++ b/src/libnrtype/FontInstance.cpp
@@ -22,7 +22,6 @@
#include <pango/pangoft2.h>
#include <2geom/pathvector.h>
#include <2geom/svg-path.h>
-#include "libnr/nr-rect.h"
#include "libnrtype/font-glyph.h"
#include "libnrtype/font-instance.h"
#include "livarot/Path.h"
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp
index a72fa0180..7e54a00e2 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -81,7 +81,7 @@ void Layout::_getGlyphTransformMatrix(int glyph_index, Geom::Affine *matrix) con
}
}
-void Layout::show(DrawingGroup *in_arena, NRRect const *paintbox) const
+void Layout::show(DrawingGroup *in_arena, Geom::OptRect const &paintbox) const
{
int glyph_index = 0;
for (unsigned span_index = 0 ; span_index < _spans.size() ; span_index++) {
@@ -99,13 +99,14 @@ void Layout::show(DrawingGroup *in_arena, NRRect const *paintbox) const
}
glyph_index++;
}
- nr_text->setPaintBox(paintbox ? paintbox->upgrade_2geom() : Geom::OptRect());
+ nr_text->setPaintBox(paintbox);
in_arena->prependChild(nr_text);
}
}
-void Layout::getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform, int start, int length) const
+Geom::OptRect Layout::bounds(Geom::Affine const &transform, int start, int length) const
{
+ Geom::OptRect bbox;
for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; glyph_index++) {
if (_characters[_glyphs[glyph_index].in_character].in_glyph == -1) continue;
if (start != -1 && (int) _glyphs[glyph_index].in_character < start) continue;
@@ -122,31 +123,19 @@ void Layout::getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform,
if(_glyphs[glyph_index].span(this).font) {
Geom::OptRect glyph_rect = _glyphs[glyph_index].span(this).font->BBox(_glyphs[glyph_index].glyph);
if (glyph_rect) {
- Geom::Point bmi = glyph_rect->min(), bma = glyph_rect->max();
- Geom::Point tlp(bmi[0],bmi[1]), trp(bma[0],bmi[1]), blp(bmi[0],bma[1]), brp(bma[0],bma[1]);
- tlp *= total_transform;
- trp *= total_transform;
- blp *= total_transform;
- brp *= total_transform;
- *glyph_rect = Geom::Rect(tlp,trp);
- glyph_rect->expandTo(blp);
- glyph_rect->expandTo(brp);
- if ( (glyph_rect->min())[0] < bounding_box->x0 ) bounding_box->x0=(glyph_rect->min())[0];
- if ( (glyph_rect->max())[0] > bounding_box->x1 ) bounding_box->x1=(glyph_rect->max())[0];
- if ( (glyph_rect->min())[1] < bounding_box->y0 ) bounding_box->y0=(glyph_rect->min())[1];
- if ( (glyph_rect->max())[1] > bounding_box->y1 ) bounding_box->y1=(glyph_rect->max())[1];
+ bbox.unionWith(*glyph_rect * total_transform);
}
}
}
+ return bbox;
}
void Layout::print(SPPrintContext *ctx,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox,
Geom::Affine const &ctm) const
{
if (_input_stream.empty()) return;
- Geom::Affine ctm_2geom(ctm);
Direction block_progression = _blockProgression();
bool text_to_path = ctx->module->textToPath();
for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; ) {
@@ -166,9 +155,9 @@ void Layout::print(SPPrintContext *ctx,
_getGlyphTransformMatrix(glyph_index, &glyph_matrix);
Geom::PathVector temp_pv = (*pv) * glyph_matrix;
if (!text_source->style->fill.isNone())
- sp_print_fill(ctx, temp_pv, &ctm_2geom, text_source->style, pbox, dbox, bbox);
+ sp_print_fill(ctx, temp_pv, ctm, text_source->style, pbox, dbox, bbox);
if (!text_source->style->stroke.isNone())
- sp_print_stroke(ctx, temp_pv, &ctm_2geom, text_source->style, pbox, dbox, bbox);
+ sp_print_stroke(ctx, temp_pv, ctm, text_source->style, pbox, dbox, bbox);
}
glyph_index++;
} else {
@@ -240,7 +229,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const
if (pathv) {
Geom::PathVector pathv_trans = (*pathv) * glyph_matrix;
SPStyle const *style = text_source->style;
- ctx->renderPathVector(pathv_trans, style, NULL);
+ ctx->renderPathVector(pathv_trans, style, Geom::OptRect());
}
glyph_index++;
continue;
@@ -302,7 +291,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const
ctx->pushLayer();
}
if (glyph_index - first_index > 0)
- ctx->renderGlyphtext(span.font->pFont, &font_matrix, glyphtext, style);
+ ctx->renderGlyphtext(span.font->pFont, font_matrix, glyphtext, style);
if (opacity != 1.0) {
ctx->popLayer();
ctx->popState();
@@ -388,9 +377,9 @@ Glib::ustring Layout::dumpAsText() const
for (unsigned char_index = 0 ; char_index < _characters.size() ; char_index++) {
if (_characters[char_index].in_span != span_index) continue;
if (_input_stream[_spans[span_index].in_input_stream_item]->Type() != TEXT_SOURCE) {
- snprintf(line, sizeof(line), " %d: control x=%f flags=%03x glyph=%d\n", char_index, _characters[char_index].x, *(unsigned*)&_characters[char_index].char_attributes, _characters[char_index].in_glyph);
+ snprintf(line, sizeof(line), " %d: control x=%f flags=%03x glyph=%d\n", char_index, _characters[char_index].x, *(unsigned*) &_characters[char_index].char_attributes, _characters[char_index].in_glyph);
} else {
- snprintf(line, sizeof(line), " %d: '%c' x=%f flags=%03x glyph=%d\n", char_index, *iter_char, _characters[char_index].x, *(unsigned*)&_characters[char_index].char_attributes, _characters[char_index].in_glyph);
+ snprintf(line, sizeof(line), " %d: '%c' x=%f flags=%03x glyph=%d\n", char_index, *iter_char, _characters[char_index].x, *(unsigned*) &_characters[char_index].char_attributes, _characters[char_index].in_glyph);
iter_char++;
}
result += line;
diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h
index 25f80e9e9..4406d9f93 100644
--- a/src/libnrtype/Layout-TNG.h
+++ b/src/libnrtype/Layout-TNG.h
@@ -14,7 +14,6 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include <libnr/nr-rect.h>
#include <2geom/d2.h>
#include <2geom/affine.h>
#include <glibmm/ustring.h>
@@ -328,7 +327,7 @@ public:
\param in_arena The arena to add the glyphs group to
\param paintbox The current rendering tile
*/
- void show(DrawingGroup *in_arena, NRRect const *paintbox) const;
+ void show(DrawingGroup *in_arena, Geom::OptRect const &paintbox) const;
/** Calculates the smallest rectangle completely enclosing all the
glyphs.
@@ -336,7 +335,7 @@ public:
\param transform The transform to be applied to the entire object
prior to calculating its bounds.
*/
- void getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform, int start = -1, int length = -1) const;
+ Geom::OptRect bounds(Geom::Affine const &transform, int start = -1, int length = -1) const;
/** Sends all the glyphs to the given print context.
\param ctx I have
@@ -345,7 +344,7 @@ public:
\param bbox parameters
\param ctm do yet
*/
- void print(SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, Geom::Affine const &ctm) const;
+ void print(SPPrintContext *ctx, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox, Geom::Affine const &ctm) const;
#ifdef HAVE_CAIRO_PDF
/** Renders all the glyphs to the given Cairo rendering context.
diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h
index 392ac20bf..3ca3feee4 100644
--- a/src/libnrtype/font-instance.h
+++ b/src/libnrtype/font-instance.h
@@ -7,11 +7,9 @@
#include <require-config.h>
#include "FontFactory.h"
-#include <libnr/nr-forward.h>
#include <libnrtype/nrtype-forward.h>
#include <libnrtype/font-style.h>
#include <livarot/livarot-forward.h>
-#include "libnr/nr-rect.h"
#include <2geom/d2.h>
// the font_instance are the template of several raster_font; they provide metrics and outlines
diff --git a/src/libnrtype/nr-type-primitives.cpp b/src/libnrtype/nr-type-primitives.cpp
index 34b1e43b8..2fbc18ffd 100644
--- a/src/libnrtype/nr-type-primitives.cpp
+++ b/src/libnrtype/nr-type-primitives.cpp
@@ -15,7 +15,6 @@
#include <stdlib.h>
#include <string.h>
#include <glib/gmem.h>
-#include <libnr/nr-macros.h>
#include "nr-type-primitives.h"
/**
diff --git a/src/livarot/Path.h b/src/livarot/Path.h
index 78e90c34f..22d989778 100644
--- a/src/livarot/Path.h
+++ b/src/livarot/Path.h
@@ -12,7 +12,6 @@
#include <vector>
#include "LivarotDefs.h"
#include "livarot/livarot-forward.h"
-#include <libnr/nr-rect-l.h>
#include <2geom/point.h>
struct SPStyle;
@@ -112,7 +111,6 @@ public:
// transforms a description in a polyline (for stroking and filling)
// treshhold is the max length^2 (sort of)
void Convert (double treshhold);
- void Convert(NRRectL *area, double treshhold);
void ConvertEvenLines (double treshhold); // decomposes line segments too, for later recomposition
// same function for use when you want to later recompose the curves from the polyline
void ConvertWithBackData (double treshhold);
diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp
index 57609d1a2..ed5f03f80 100644
--- a/src/livarot/PathConversion.cpp
+++ b/src/livarot/PathConversion.cpp
@@ -6,10 +6,11 @@
*
*/
+#include <glib.h>
+#include <2geom/transforms.h>
#include "Path.h"
#include "Shape.h"
#include "livarot/path-description.h"
-#include <2geom/transforms.h>
/*
* path description -> polyline
@@ -401,282 +402,6 @@ void Path::Convert(double treshhold)
}
}
-#define POINT_RELATION_TO_AREA(pt, area) ((pt)[0] < (area)->x0 ? 1 : ((pt)[0] > (area)->x1 ? 2 : ((pt)[1] < (area)->y0 ? 3 : ((pt)[1] > (area)->y1 ? 4 : 0))))
-
-void Path::Convert(NRRectL *area, double treshhold)
-{
- if ( descr_flags & descr_adding_bezier ) {
- CancelBezier();
- }
-
- if ( descr_flags & descr_doing_subpath ) {
- CloseSubpath();
- }
-
- SetBackData(false);
- ResetPoints();
- if ( descr_cmd.empty() ) {
- return;
- }
-
- Geom::Point curX;
- int curP = 1;
- int lastMoveTo = 0;
- short last_point_relation = 0;
- short curent_point_relation = 0;
- bool last_start_elimination = false;
- bool start_elimination = false;
- bool replace = false;
-
- // first point
- {
- int const firstTyp = descr_cmd[0]->getType();
- if ( firstTyp == descr_moveto ) {
- curX = dynamic_cast<PathDescrMoveTo *>(descr_cmd[0])->p;
- } else {
- curP = 0;
- curX[0] = curX[1] = 0;
- }
-
- last_point_relation = POINT_RELATION_TO_AREA(curX, area);
- lastMoveTo = AddPoint(curX, true);
- }
- descr_cmd[0]->associated = lastMoveTo;
-
- // process nodes one by one
- while ( curP < int(descr_cmd.size()) ) {
-
- int const nType = descr_cmd[curP]->getType();
- Geom::Point nextX;
-
- switch (nType) {
- case descr_forced: {
- descr_cmd[curP]->associated = AddForcedPoint(curX);
- last_point_relation = 0;
- curP++;
- break;
- }
-
- case descr_moveto: {
- PathDescrMoveTo *nData = dynamic_cast<PathDescrMoveTo *>(descr_cmd[curP]);
- nextX = nData->p;
- lastMoveTo = AddPoint(nextX, true);
- descr_cmd[curP]->associated = lastMoveTo;
-
- last_point_relation = POINT_RELATION_TO_AREA(nextX, area);
- start_elimination = false;
-
- curP++;
- break;
- }
-
- case descr_close: {
- nextX = pts[lastMoveTo].p;
- descr_cmd[curP]->associated = AddPoint(nextX, false);
- if ( descr_cmd[curP]->associated < 0 ) {
- if ( curP == 0 ) {
- descr_cmd[curP]->associated = 0;
- } else {
- descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated;
- }
- }
- if ( descr_cmd[curP]->associated > 0 ) {
- pts[descr_cmd[curP]->associated].closed = true;
- }
- last_point_relation = 0;
- curP++;
- break;
- }
-
- case descr_lineto: {
- PathDescrLineTo *nData = dynamic_cast<PathDescrLineTo *>(descr_cmd[curP]);
- nextX = nData->p;
- curent_point_relation = POINT_RELATION_TO_AREA(nextX, area);
- replace = false;
- last_start_elimination = start_elimination;
- if (curent_point_relation > 0 && curent_point_relation == last_point_relation) {
- if (!start_elimination) {
- start_elimination = true;
- } else {
- replace = true;
- descr_cmd[curP]->associated = ReplacePoint(nextX);
- }
- } else {
- start_elimination = false;
- }
-
- if (!replace) {
- descr_cmd[curP]->associated = AddPoint(nextX, false);
- }
-
- if ( descr_cmd[curP]->associated < 0 ) {
- // point is not added as position is equal to the last added
- start_elimination = last_start_elimination;
- if ( curP == 0 ) {
- descr_cmd[curP]->associated = 0;
- } else {
- descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated;
- }
- }
- last_point_relation = curent_point_relation;
- curP++;
- break;
- }
-
- case descr_cubicto: {
- PathDescrCubicTo *nData = dynamic_cast<PathDescrCubicTo *>(descr_cmd[curP]);
- nextX = nData->p;
-
- curent_point_relation = POINT_RELATION_TO_AREA(nextX, area);
- replace = false;
- last_start_elimination = start_elimination;
- if (curent_point_relation > 0 && curent_point_relation == last_point_relation &&
- curent_point_relation == POINT_RELATION_TO_AREA(curX + (nData->start), area) &&
- curent_point_relation == POINT_RELATION_TO_AREA(nextX + (nData->end), area))
- {
- if (!start_elimination) {
- start_elimination = true;
- } else {
- replace = true;
- descr_cmd[curP]->associated = ReplacePoint(nextX);
- }
- } else {
- start_elimination = false;
- }
-
- if (!replace) {
- RecCubicTo(curX, nData->start, nextX, nData->end, treshhold, 8);
- descr_cmd[curP]->associated = AddPoint(nextX,false);
- }
-
- if ( descr_cmd[curP]->associated < 0 ) {
- // point is not added as position is equal to the last added
- start_elimination = last_start_elimination;
- if ( curP == 0 ) {
- descr_cmd[curP]->associated = 0;
- } else {
- descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated;
- }
- }
- last_point_relation = curent_point_relation;
- curP++;
- break;
- }
-
- case descr_arcto: {
- PathDescrArcTo *nData = dynamic_cast<PathDescrArcTo *>(descr_cmd[curP]);
- nextX = nData->p;
- DoArc(curX, nextX, nData->rx, nData->ry, nData->angle, nData->large, nData->clockwise, treshhold);
- descr_cmd[curP]->associated = AddPoint(nextX, false);
- if ( descr_cmd[curP]->associated < 0 ) {
- if ( curP == 0 ) {
- descr_cmd[curP]->associated = 0;
- } else {
- descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated;
- }
- }
- last_point_relation = 0;
-
- curP++;
- break;
- }
-
- case descr_bezierto: {
- PathDescrBezierTo *nBData = dynamic_cast<PathDescrBezierTo *>(descr_cmd[curP]);
- int nbInterm = nBData->nb;
- nextX = nBData->p;
- int curBD = curP;
-
- curP++;
- int ip = curP;
- PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
-
- if ( nbInterm == 1 ) {
- Geom::Point const midX = nData->p;
- RecBezierTo(midX, curX, nextX, treshhold, 8);
- } else if ( nbInterm > 1 ) {
- Geom::Point bx = curX;
- Geom::Point cx = curX;
- Geom::Point dx = curX;
-
- dx = nData->p;
- ip++;
- nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
-
- cx = 2 * bx - dx;
-
- for (int k = 0; k < nbInterm - 1; k++) {
- bx = cx;
- cx = dx;
-
- dx = nData->p;
- ip++;
- nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
-
- Geom::Point stx = (bx + cx) / 2;
- if ( k > 0 ) {
- descr_cmd[ip - 2]->associated = AddPoint(stx, false);
- if ( descr_cmd[ip - 2]->associated < 0 ) {
- if ( curP == 0 ) {
- descr_cmd[ip - 2]->associated = 0;
- } else {
- descr_cmd[ip - 2]->associated = descr_cmd[ip - 3]->associated;
- }
- }
- }
-
- {
- Geom::Point const mx = (cx + dx) / 2;
- RecBezierTo(cx, stx, mx, treshhold, 8);
- }
- }
-
- {
- bx = cx;
- cx = dx;
-
- dx = nextX;
- dx = 2 * dx - cx;
-
- Geom::Point stx = (bx + cx) / 2;
-
- descr_cmd[ip - 1]->associated = AddPoint(stx, false);
- if ( descr_cmd[ip - 1]->associated < 0 ) {
- if ( curP == 0 ) {
- descr_cmd[ip - 1]->associated = 0;
- } else {
- descr_cmd[ip - 1]->associated = descr_cmd[ip - 2]->associated;
- }
- }
-
- {
- Geom::Point mx = (cx + dx) / 2;
- RecBezierTo(cx, stx, mx, treshhold, 8);
- }
- }
- }
-
- descr_cmd[curBD]->associated = AddPoint(nextX, false);
- if ( descr_cmd[curBD]->associated < 0 ) {
- if ( curP == 0 ) {
- descr_cmd[curBD]->associated = 0;
- } else {
- descr_cmd[curBD]->associated = descr_cmd[curBD - 1]->associated;
- }
- }
-
- last_point_relation = 0;
-
- curP += nbInterm;
- break;
- }
- }
-
- curX = nextX;
- }
-}
-
-
void Path::ConvertEvenLines(double treshhold)
{
if ( descr_flags & descr_adding_bezier ) {
diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp
index 708d20f3f..e47ed8916 100644
--- a/src/livarot/PathCutting.cpp
+++ b/src/livarot/PathCutting.cpp
@@ -20,7 +20,6 @@
#include "Path.h"
#include "style.h"
#include "livarot/path-description.h"
-#include "libnr/nr-convert2geom.h"
#include <2geom/pathvector.h>
#include <2geom/point.h>
#include <2geom/affine.h>
diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp
index d4fc7eb30..d170e5d3a 100644
--- a/src/livarot/PathOutline.cpp
+++ b/src/livarot/PathOutline.cpp
@@ -8,7 +8,6 @@
#include "livarot/Path.h"
#include "livarot/path-description.h"
-#include <libnr/nr-point-fns.h>
/*
* the "outliner"
diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp
index d24e4b99d..805741d3f 100644
--- a/src/livarot/Shape.cpp
+++ b/src/livarot/Shape.cpp
@@ -12,7 +12,6 @@
#include "Shape.h"
#include "livarot/sweep-event-queue.h"
#include "livarot/sweep-tree-list.h"
-#include <libnr/nr-point-fns.h>
/*
* Shape instances handling.
diff --git a/src/livarot/ShapeRaster.cpp b/src/livarot/ShapeRaster.cpp
index 7b00cdc6b..b7b087fba 100644
--- a/src/livarot/ShapeRaster.cpp
+++ b/src/livarot/ShapeRaster.cpp
@@ -12,7 +12,6 @@
#include "AlphaLigne.h"
#include "BitLigne.h"
-#include <libnr/nr-point-fns.h>
#include "livarot/sweep-event-queue.h"
#include "livarot/sweep-tree-list.h"
#include "livarot/sweep-tree.h"
diff --git a/src/livarot/sweep-tree.cpp b/src/livarot/sweep-tree.cpp
index 9ff1143ce..0cfd6bc52 100644
--- a/src/livarot/sweep-tree.cpp
+++ b/src/livarot/sweep-tree.cpp
@@ -1,4 +1,3 @@
-#include "libnr/nr-point-fns.h"
#include "livarot/sweep-event-queue.h"
#include "livarot/sweep-tree-list.h"
#include "livarot/sweep-tree.h"
diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp
index a002901b2..9bac3b860 100644
--- a/src/live_effects/lpe-curvestitch.cpp
+++ b/src/live_effects/lpe-curvestitch.cpp
@@ -30,7 +30,6 @@
#include <2geom/affine.h>
#include "ui/widget/scalar.h"
-#include "libnr/nr-values.h"
namespace Inkscape {
namespace LivePathEffect {
diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp
index 96d465569..8b5badf5f 100644
--- a/src/live_effects/lpe-extrude.cpp
+++ b/src/live_effects/lpe-extrude.cpp
@@ -174,10 +174,10 @@ LPEExtrude::resetDefaults(SPItem * item)
using namespace Geom;
- Geom::OptRect bbox = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox = item->geometricBounds();
if (bbox) {
- Interval boundingbox_X = (*bbox)[Geom::X];
- Interval boundingbox_Y = (*bbox)[Geom::Y];
+ Interval const &boundingbox_X = (*bbox)[Geom::X];
+ Interval const &boundingbox_Y = (*bbox)[Geom::Y];
extrude_vector.set_and_write_new_values( Geom::Point(boundingbox_X.middle(), boundingbox_Y.middle()),
(boundingbox_X.extent() + boundingbox_Y.extent())*Geom::Point(-0.05,0.2) );
}
diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp
index 02d24752b..2d043ca91 100644
--- a/src/live_effects/lpe-mirror_symmetry.cpp
+++ b/src/live_effects/lpe-mirror_symmetry.cpp
@@ -45,8 +45,10 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem)
{
using namespace Geom;
+ // fixme: what happens if the bbox is empty?
+ // fixme: this is probably wrong
Geom::Affine t = lpeitem->i2dt_affine();
- Geom::Rect bbox = *lpeitem->getBounds(t); // fixme: what happens if getBounds does not return a valid rect?
+ Geom::Rect bbox = *lpeitem->desktopVisualBounds();
Point A(bbox.left(), bbox.bottom());
Point B(bbox.left(), bbox.top());
diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp
index 671d88a8b..8324271ed 100644
--- a/src/live_effects/lpe-rough-hatches.cpp
+++ b/src/live_effects/lpe-rough-hatches.cpp
@@ -31,7 +31,6 @@
#include <2geom/affine.h>
#include "ui/widget/scalar.h"
-#include "libnr/nr-values.h"
namespace Inkscape {
namespace LivePathEffect {
@@ -557,7 +556,7 @@ LPERoughHatches::resetDefaults(SPItem * item)
{
Effect::resetDefaults(item);
- Geom::OptRect bbox = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox = item->geometricBounds();
Geom::Point origin(0.,0.);
Geom::Point vector(50.,0.);
if (bbox) {
diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp
index 382231378..c241b9a4c 100644
--- a/src/live_effects/lpegroupbbox.cpp
+++ b/src/live_effects/lpegroupbbox.cpp
@@ -34,7 +34,7 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute)
transform = Geom::identity();
}
- Geom::OptRect bbox = lpeitem->getBounds(transform, SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox = lpeitem->geometricBounds(transform);
if (bbox) {
boundingbox_X = (*bbox)[Geom::X];
boundingbox_Y = (*bbox)[Geom::Y];
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp
index fc15ce1f5..5454a5408 100644
--- a/src/live_effects/parameter/parameter.cpp
+++ b/src/live_effects/parameter/parameter.cpp
@@ -9,7 +9,6 @@
#include "live_effects/parameter/parameter.h"
#include "live_effects/effect.h"
#include "svg/svg.h"
-#include "libnr/nr-values.h"
#include "xml/repr.h"
#include <gtkmm.h>
#include "ui/widget/registered-widget.h"
diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp
index cdfb1fb50..d5a6e9291 100644
--- a/src/live_effects/parameter/random.cpp
+++ b/src/live_effects/parameter/random.cpp
@@ -9,7 +9,6 @@
#include "live_effects/parameter/random.h"
#include "live_effects/effect.h"
#include "svg/svg.h"
-#include "libnr/nr-values.h"
#include "ui/widget/registered-widget.h"
#include <gtkmm.h>
#include "ui/widget/random.h"
diff --git a/src/main.cpp b/src/main.cpp
index ace99f519..501a3e5d2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1195,8 +1195,8 @@ do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const g
doc->ensureUpToDate();
SPItem *item = ((SPItem *) o);
- // "true" SVG bbox for scripting
- Geom::OptRect area = item->getBounds(item->i2doc_affine());
+ // visual bbox in document coords for scripting
+ Geom::OptRect area = item->documentVisualBounds();
if (area) {
Inkscape::SVGOStringStream os;
if (extent) {
@@ -1226,7 +1226,7 @@ do_query_all_recurse (SPObject *o)
{
SPItem *item = ((SPItem *) o);
if (o->getId() && SP_IS_ITEM(item)) {
- Geom::OptRect area = item->getBounds(item->i2doc_affine());
+ Geom::OptRect area = item->documentVisualBounds();
if (area) {
Inkscape::SVGOStringStream os;
os << o->getId();
@@ -1320,8 +1320,7 @@ sp_do_export_png(SPDocument *doc)
// write object bbox to area
doc->ensureUpToDate();
- Geom::OptRect areaMaybe;
- static_cast<SPItem *>(o_area)->invoke_bbox( areaMaybe, static_cast<SPItem *>(o_area)->i2dt_affine(), TRUE);
+ Geom::OptRect areaMaybe = static_cast<SPItem *>(o_area)->desktopVisualBounds();
if (areaMaybe) {
area = *areaMaybe;
} else {
diff --git a/src/marker.cpp b/src/marker.cpp
index c8fa9218d..e75cdff43 100644
--- a/src/marker.cpp
+++ b/src/marker.cpp
@@ -17,7 +17,6 @@
#include <string>
#include "config.h"
-#include "libnr/nr-convert2geom.h"
#include <2geom/affine.h>
#include <2geom/transforms.h>
#include "svg/svg.h"
@@ -45,7 +44,7 @@ static Inkscape::XML::Node *sp_marker_write (SPObject *object, Inkscape::XML::Do
static Inkscape::DrawingItem *sp_marker_private_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
static void sp_marker_private_hide (SPItem *item, unsigned int key);
-static void sp_marker_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_marker_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static void sp_marker_print (SPItem *item, SPPrintContext *ctx);
static void sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destroyitems);
@@ -349,10 +348,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags)
rctx.i2doc = Geom::identity();
rctx.i2vp = Geom::identity();
/* Set up viewport */
- rctx.vp.x0 = 0.0;
- rctx.vp.y0 = 0.0;
- rctx.vp.x1 = marker->markerWidth.computed;
- rctx.vp.y1 = marker->markerHeight.computed;
+ rctx.viewport = Geom::Rect::from_xywh(0, 0, marker->markerWidth.computed, marker->markerHeight.computed);
/* Start with identity transform */
marker->c2p.setIdentity();
@@ -361,20 +357,20 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags)
if (marker->viewBox) {
vb = *marker->viewBox;
} else {
- vb = *(rctx.vp.upgrade_2geom());
+ vb = rctx.viewport;
}
/* Now set up viewbox transformation */
/* Determine actual viewbox in viewport coordinates */
if (marker->aspect_align == SP_ASPECT_NONE) {
x = 0.0;
y = 0.0;
- width = rctx.vp.x1 - rctx.vp.x0;
- height = rctx.vp.y1 - rctx.vp.y0;
+ width = rctx.viewport.width();
+ height = rctx.viewport.height();
} else {
double scalex, scaley, scale;
/* Things are getting interesting */
- scalex = (rctx.vp.x1 - rctx.vp.x0) / (vb.width());
- scaley = (rctx.vp.y1 - rctx.vp.y0) / (vb.height());
+ scalex = rctx.viewport.width() / (vb.width());
+ scaley = rctx.viewport.height() / (vb.height());
scale = (marker->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley);
width = (vb.width()) * scale;
height = (vb.height()) * scale;
@@ -385,36 +381,36 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags)
y = 0.0;
break;
case SP_ASPECT_XMID_YMIN:
- x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width);
+ x = 0.5 * (rctx.viewport.width() - width);
y = 0.0;
break;
case SP_ASPECT_XMAX_YMIN:
- x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width);
+ x = 1.0 * (rctx.viewport.width() - width);
y = 0.0;
break;
case SP_ASPECT_XMIN_YMID:
x = 0.0;
- y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ y = 0.5 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMID_YMID:
- x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width);
- y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ x = 0.5 * (rctx.viewport.width() - width);
+ y = 0.5 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMAX_YMID:
- x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width);
- y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ x = 1.0 * (rctx.viewport.width() - width);
+ y = 0.5 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMIN_YMAX:
x = 0.0;
- y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ y = 1.0 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMID_YMAX:
- x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width);
- y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ x = 0.5 * (rctx.viewport.width() - width);
+ y = 1.0 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMAX_YMAX:
- x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width);
- y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ x = 1.0 * (rctx.viewport.width() - width);
+ y = 1.0 * (rctx.viewport.height() - height);
break;
default:
x = 0.0;
@@ -432,10 +428,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags)
/* If viewBox is set reinitialize child viewport */
/* Otherwise it already correct */
if (marker->viewBox) {
- rctx.vp.x0 = marker->viewBox->min()[Geom::X];
- rctx.vp.y0 = marker->viewBox->min()[Geom::Y];
- rctx.vp.x1 = marker->viewBox->max()[Geom::X];
- rctx.vp.y1 = marker->viewBox->max()[Geom::Y];
+ rctx.viewport = *marker->viewBox;
rctx.i2vp = Geom::identity();
}
@@ -541,10 +534,11 @@ sp_marker_private_hide (SPItem */*item*/, unsigned int /*key*/)
/**
* This routine is disabled to break propagation.
*/
-static void
-sp_marker_bbox(SPItem const *, NRRect *, Geom::Affine const &, unsigned const)
+static Geom::OptRect
+sp_marker_bbox(SPItem const *, Geom::Affine const &, SPItem::BBoxType)
{
- /* Break propagation */
+ /* Break propagation */
+ return Geom::OptRect();
}
/**
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 987b027b0..7aa8a9c08 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -135,15 +135,14 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
if (SP_IS_GROUP(o)) {
_findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine);
} else {
- Geom::OptRect bbox_of_item = Geom::Rect();
+ Geom::OptRect bbox_of_item;
if (clip_or_mask) {
// Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to
// insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine)
- item->invoke_bbox(bbox_of_item,
- item->i2doc_affine() * additional_affine * _snapmanager->getDesktop()->doc2dt(),
- true);
+ bbox_of_item = item->visualBounds(item->i2doc_affine() * additional_affine *
+ _snapmanager->getDesktop()->doc2dt());
} else {
- item->invoke_bbox( bbox_of_item, item->i2dt_affine(), true);
+ bbox_of_item = item->desktopVisualBounds();
}
if (bbox_of_item) {
// See if the item is within range
@@ -188,7 +187,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t,
Preferences *prefs = Preferences::get();
bool prefs_bbox = prefs->getBool("/tools/bounding_box");
bbox_type = !prefs_bbox ?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
}
// Consider the page border for snapping to
@@ -258,7 +257,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t,
// Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox
// of the item AND the bbox of the clipping path at the same time
if (!(*i).clip_or_mask) {
- Geom::OptRect b = root_item->getBboxDesktop(bbox_type);
+ Geom::OptRect b = root_item->desktopBounds(bbox_type);
getBBoxPoints(b, _points_to_snap_to, true,
_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER),
_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT),
@@ -373,7 +372,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/,
Preferences *prefs = Preferences::get();
int prefs_bbox = prefs->getBool("/tools/bounding_box", 0);
bbox_type = !prefs_bbox ?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
}
// Consider the page border for snapping
@@ -452,11 +451,10 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/,
// Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox
// of the item AND the bbox of the clipping path at the same time
if (!(*i).clip_or_mask) {
- Geom::OptRect rect;
- root_item->invoke_bbox( rect, i2doc, TRUE, bbox_type);
+ Geom::OptRect rect = root_item->bounds(bbox_type, i2doc);
if (rect) {
Geom::PathVector *path = _getPathvFromRect(*rect);
- rect = root_item->getBboxDesktop(bbox_type);
+ rect = root_item->desktopBounds(bbox_type);
_paths_to_snap_to->push_back(SnapCandidatePath(path, SNAPTARGET_BBOX_EDGE, rect));
}
}
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index 57205a436..d823c1daa 100644
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -34,7 +34,6 @@
#include <2geom/bezier-utils.h>
#include "display/canvas-bpath.h"
#include <glibmm/i18n.h>
-#include "libnr/in-svg-plane.h"
#include "context-fns.h"
#include "sp-namedview.h"
#include "xml/repr.h"
@@ -69,6 +68,8 @@ static SPDrawContextClass *pencil_parent_class;
static Geom::Point pencil_drag_origin_w(0, 0);
static bool pencil_within_tolerance = false;
+static bool in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; }
+
/**
* Register SPPencilContext class with Gdk and return its type number.
*/
diff --git a/src/print.cpp b/src/print.cpp
index 2eadf0fa9..d2fc72175 100644
--- a/src/print.cpp
+++ b/src/print.cpp
@@ -27,17 +27,8 @@
#include "ui/dialog/print.h"
-
-/* Identity typedef */
-
-unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity)
-{
- Geom::Affine const ntransform(transform);
- return sp_print_bind(ctx, &ntransform, opacity);
-}
-
unsigned int
-sp_print_bind(SPPrintContext *ctx, Geom::Affine const *transform, float opacity)
+sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity)
{
return ctx->module->bind(transform, opacity);
}
@@ -55,15 +46,15 @@ sp_print_comment(SPPrintContext *ctx, char const *comment)
}
unsigned int
-sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
+sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
return ctx->module->fill(pathv, ctm, style, pbox, dbox, bbox);
}
unsigned int
-sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
+sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
return ctx->module->stroke(pathv, ctm, style, pbox, dbox, bbox);
}
@@ -71,7 +62,7 @@ sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine
unsigned int
sp_print_image_R8G8B8A8_N(SPPrintContext *ctx,
guchar *px, unsigned int w, unsigned int h, unsigned int rs,
- Geom::Affine const *transform, SPStyle const *style)
+ Geom::Affine const &transform, SPStyle const *style)
{
return ctx->module->image(px, w, h, rs, transform, style);
}
diff --git a/src/print.h b/src/print.h
index 6bdbe4b82..422f18669 100644
--- a/src/print.h
+++ b/src/print.h
@@ -17,23 +17,21 @@
#include "forward.h"
#include "extension/extension-forward.h"
-struct NRRect;
struct SPPrintContext {
Inkscape::Extension::Print *module;
};
unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity);
-unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const *transform, float opacity);
unsigned int sp_print_release(SPPrintContext *ctx);
unsigned int sp_print_comment(SPPrintContext *ctx, char const *comment);
-unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
-unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *transform, SPStyle const *style,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
+unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox);
+unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox);
unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx,
guchar *px, unsigned int w, unsigned int h, unsigned int rs,
- Geom::Affine const *transform, SPStyle const *style);
+ Geom::Affine const &transform, SPStyle const *style);
unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p,
SPStyle const *style);
diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp
index a503fea35..6dd8d6a79 100644
--- a/src/removeoverlap.cpp
+++ b/src/removeoverlap.cpp
@@ -50,7 +50,7 @@ void removeoverlap(GSList const *const items, double const xGap, double const yG
++it)
{
using Geom::X; using Geom::Y;
- Geom::OptRect item_box((*it)->getBboxDesktop());
+ Geom::OptRect item_box((*it)->desktopVisualBounds());
if (item_box) {
Geom::Point min(item_box->min() - .5*gap);
Geom::Point max(item_box->max() + .5*gap);
diff --git a/src/satisfied-guide-cns.cpp b/src/satisfied-guide-cns.cpp
index 6d8c4d048..7aca3b0bd 100644
--- a/src/satisfied-guide-cns.cpp
+++ b/src/satisfied-guide-cns.cpp
@@ -1,5 +1,4 @@
#include <desktop-handles.h>
-#include <libnr/nr-point-fns.h>
#include <sp-guide.h>
#include <sp-guide-constraint.h>
#include <sp-namedview.h>
diff --git a/src/selcue.cpp b/src/selcue.cpp
index c647c1f96..dbcaf4cc3 100644
--- a/src/selcue.cpp
+++ b/src/selcue.cpp
@@ -68,8 +68,6 @@ void Inkscape::SelCue::_updateItemBboxes()
g_return_if_fail(_selection != NULL);
int prefs_bbox = prefs->getBool("/tools/bounding_box");
- SPItem::BBoxType bbox_type = !prefs_bbox ?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
GSList const *items = _selection->itemList();
if (_item_bboxes.size() != g_slist_length((GSList *) items)) {
@@ -83,7 +81,8 @@ void Inkscape::SelCue::_updateItemBboxes()
SPCanvasItem* box = _item_bboxes[bcount ++];
if (box) {
- Geom::OptRect const b = item->getBboxDesktop(bbox_type);
+ Geom::OptRect const b = (prefs_bbox == 0) ?
+ item->desktopVisualBounds() : item->desktopGeometricBounds();
if (b) {
sp_canvas_item_show(box);
@@ -118,13 +117,12 @@ void Inkscape::SelCue::_newItemBboxes()
g_return_if_fail(_selection != NULL);
int prefs_bbox = prefs->getBool("/tools/bounding_box");
- SPItem::BBoxType bbox_type = !prefs_bbox ?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) {
SPItem *item = (SPItem *) l->data;
- Geom::OptRect const b = item->getBboxDesktop(bbox_type);
+ Geom::OptRect const b = (prefs_bbox == 0) ?
+ item->desktopVisualBounds() : item->desktopGeometricBounds();
SPCanvasItem* box = NULL;
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 23991bfb6..4c3c0f197 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -85,7 +85,6 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "sp-filter-reference.h"
#include "gradient-drag.h"
#include "uri-references.h"
-#include "libnr/nr-convert2geom.h"
#include "display/curve.h"
#include "display/canvas-bpath.h"
#include "inkscape-private.h"
@@ -777,7 +776,7 @@ enclose_items(GSList const *items)
Geom::OptRect r;
for (GSList const *i = items; i; i = i->next) {
- r.unionWith(((SPItem *) i->data)->getBboxDesktop());
+ r.unionWith(((SPItem *) i->data)->desktopVisualBounds());
}
return r;
}
@@ -829,7 +828,7 @@ sp_selection_raise(SPDesktop *desktop)
for (SPObject *newref = child->next; newref; newref = newref->next) {
// if the sibling is an item AND overlaps our selection,
if (SP_IS_ITEM(newref)) {
- Geom::OptRect newref_bbox = SP_ITEM(newref)->getBboxDesktop();
+ Geom::OptRect newref_bbox = SP_ITEM(newref)->desktopVisualBounds();
if ( newref_bbox && selected->intersects(*newref_bbox) ) {
// AND if it's not one of our selected objects,
if (!g_slist_find((GSList *) items, newref)) {
@@ -924,7 +923,7 @@ sp_selection_lower(SPDesktop *desktop)
for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) {
// if the sibling is an item AND overlaps our selection,
if (SP_IS_ITEM(newref)) {
- Geom::OptRect ref_bbox = SP_ITEM(newref)->getBboxDesktop();
+ Geom::OptRect ref_bbox = SP_ITEM(newref)->desktopVisualBounds();
if ( ref_bbox && selected->intersects(*ref_bbox) ) {
// AND if it's not one of our selected objects,
if (!g_slist_find((GSList *) items, newref)) {
@@ -1481,7 +1480,7 @@ sp_selection_scale_absolute(Inkscape::Selection *selection,
if (selection->isEmpty())
return;
- Geom::OptRect const bbox(selection->bounds());
+ Geom::OptRect bbox = selection->visualBounds();
if ( !bbox ) {
return;
}
@@ -1503,7 +1502,7 @@ void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point con
if (selection->isEmpty())
return;
- Geom::OptRect const bbox(selection->bounds());
+ Geom::OptRect bbox = selection->visualBounds();
if ( !bbox ) {
return;
@@ -1621,7 +1620,7 @@ sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle)
if (selection->isEmpty())
return;
- Geom::OptRect const bbox(selection->bounds());
+ Geom::OptRect bbox = selection->visualBounds();
boost::optional<Geom::Point> center = selection->center();
if ( !bbox || !center ) {
@@ -1650,7 +1649,7 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow)
if (selection->isEmpty())
return;
- Geom::OptRect const bbox(selection->bounds());
+ Geom::OptRect bbox = selection->visualBounds();
if (!bbox) {
return;
}
@@ -1687,7 +1686,7 @@ sp_selection_scale_times(Inkscape::Selection *selection, gdouble times)
if (selection->isEmpty())
return;
- Geom::OptRect sel_bbox = selection->bounds();
+ Geom::OptRect sel_bbox = selection->visualBounds();
if (!sel_bbox) {
return;
@@ -2014,7 +2013,7 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
void scroll_to_show_item(SPDesktop *desktop, SPItem *item)
{
Geom::Rect dbox = desktop->get_display_area();
- Geom::OptRect sbox = item->getBboxDesktop();
+ Geom::OptRect sbox = item->desktopVisualBounds();
if ( sbox && dbox.contains(*sbox) == false ) {
Geom::Point const s_dt = sbox->midpoint();
@@ -2248,8 +2247,8 @@ sp_select_clone_original(SPDesktop *desktop)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool highlight = prefs->getBool("/options/highlightoriginal/value");
if (highlight) {
- Geom::OptRect a = item->getBounds(item->i2dt_affine());
- Geom::OptRect b = original->getBounds(original->i2dt_affine());
+ Geom::OptRect a = item->desktopVisualBounds();
+ Geom::OptRect b = original->desktopVisualBounds();
if ( a && b ) {
// draw a flashing line between the objects
SPCurve *curve = new SPCurve();
@@ -2291,7 +2290,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
}
doc->ensureUpToDate();
- Geom::OptRect r = selection->bounds(SPItem::RENDERING_BBOX);
+ Geom::OptRect r = selection->visualBounds();
boost::optional<Geom::Point> c = selection->center();
if ( !r || !c ) {
return;
@@ -2322,7 +2321,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
repr_copies = g_slist_prepend(repr_copies, dup);
}
- Geom::Rect bounds(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
+ Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
if (apply) {
// delete objects so that their clones don't get alerted; this object will be restored shortly
@@ -2339,7 +2338,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- gchar const *mark_id = generate_marker(repr_copies, bounds, doc,
+ gchar const *mark_id = generate_marker(repr_copies, bbox, doc,
( Geom::Affine(Geom::Translate(desktop->dt2doc(
Geom::Point(r->min()[Geom::X],
r->max()[Geom::Y]))))
@@ -2416,7 +2415,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
}
doc->ensureUpToDate();
- Geom::OptRect r = selection->bounds(SPItem::RENDERING_BBOX);
+ Geom::OptRect r = selection->visualBounds();
if ( !r ) {
return;
}
@@ -2447,7 +2446,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
// restore the z-order after prepends
repr_copies = g_slist_reverse(repr_copies);
- Geom::Rect bounds(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
+ Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
if (apply) {
// delete objects so that their clones don't get alerted; this object will be restored shortly
@@ -2464,7 +2463,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- gchar const *pat_id = pattern_tile(repr_copies, bounds, doc,
+ gchar const *pat_id = pattern_tile(repr_copies, bbox, doc,
( Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X],
r->max()[Geom::Y]))))
* parent_transform.inverse() ),
@@ -2477,8 +2476,8 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
Inkscape::XML::Node *rect = xml_doc->createElement("svg:rect");
rect->setAttribute("style", g_strdup_printf("stroke:none;fill:url(#%s)", pat_id));
- Geom::Point min = bounds.min() * parent_transform.inverse();
- Geom::Point max = bounds.max() * parent_transform.inverse();
+ Geom::Point min = bbox.min() * parent_transform.inverse();
+ Geom::Point max = bbox.max() * parent_transform.inverse();
sp_repr_set_svg_double(rect, "width", max[Geom::X] - min[Geom::X]);
sp_repr_set_svg_double(rect, "height", max[Geom::Y] - min[Geom::Y]);
@@ -2663,7 +2662,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
// Get the bounding box of the selection
document->ensureUpToDate();
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (!bbox) {
desktop->clearWaitingCursor();
return; // exceptional situation, so not bother with a translatable error message, just quit quietly
@@ -3200,7 +3199,7 @@ fit_canvas_to_selection(SPDesktop *desktop, bool with_margins)
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to fit canvas to."));
return false;
}
- Geom::OptRect const bbox(desktop->selection->bounds(SPItem::RENDERING_BBOX));
+ Geom::OptRect const bbox(desktop->selection->visualBounds());
if (bbox) {
doc->fitToRect(*bbox, with_margins);
return true;
@@ -3232,7 +3231,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins)
doc->ensureUpToDate();
SPItem const *const root = doc->getRoot();
- Geom::OptRect const bbox(root->getBounds(root->i2dt_affine(), SPItem::RENDERING_BBOX));
+ Geom::OptRect bbox = root->desktopVisualBounds();
if (bbox) {
doc->fitToRect(*bbox, with_margins);
return true;
diff --git a/src/selection.cpp b/src/selection.cpp
index 677e57d5f..92b35bce7 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -362,50 +362,48 @@ Inkscape::XML::Node *Selection::singleRepr() {
return obj ? obj->getRepr() : NULL;
}
-NRRect *Selection::bounds(NRRect *bbox, SPItem::BBoxType type) const
+Geom::OptRect Selection::bounds(SPItem::BBoxType type) const
{
- g_return_val_if_fail (bbox != NULL, NULL);
- *bbox = NRRect(bounds(type));
- return bbox;
+ return (type == SPItem::GEOMETRIC_BBOX) ?
+ geometricBounds() : visualBounds();
}
-Geom::OptRect Selection::bounds(SPItem::BBoxType type) const
+Geom::OptRect Selection::geometricBounds() const
{
GSList const *items = const_cast<Selection *>(this)->itemList();
Geom::OptRect bbox;
for ( GSList const *i = items ; i != NULL ; i = i->next ) {
- bbox.unionWith(SP_ITEM(i->data)->getBboxDesktop(type));
+ bbox.unionWith(SP_ITEM(i->data)->desktopGeometricBounds());
}
return bbox;
}
-NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const {
- g_return_val_if_fail (bbox != NULL, NULL);
+Geom::OptRect Selection::visualBounds() const
+{
+ GSList const *items = const_cast<Selection *>(this)->itemList();
- GSList const *items=const_cast<Selection *>(this)->itemList();
- if (!items) {
- bbox->x0 = bbox->y0 = bbox->x1 = bbox->y1 = 0.0;
- return bbox;
+ Geom::OptRect bbox;
+ for ( GSList const *i = items ; i != NULL ; i = i->next ) {
+ bbox.unionWith(SP_ITEM(i->data)->desktopVisualBounds());
}
+ return bbox;
+}
- bbox->x0 = bbox->y0 = 1e18;
- bbox->x1 = bbox->y1 = -1e18;
+Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const
+{
+ Geom::OptRect bbox;
+ GSList const *items = const_cast<Selection *>(this)->itemList();
+ if (!items) return bbox;
for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) {
- SPItem *item=SP_ITEM(iter->data);
- Geom::Affine i2doc(item->i2doc_affine());
- item->invoke_bbox( bbox, i2doc, FALSE, type);
+ SPItem *item = SP_ITEM(iter->data);
+ bbox |= item->documentBounds(type);
}
return bbox;
}
-Geom::OptRect Selection::boundsInDocument(SPItem::BBoxType type) const {
- NRRect r;
- return to_2geom(boundsInDocument(&r, type));
-}
-
/** Extract the position of the center from the first selected object */
// If we have a selection of multiple items, then the center of the first item
// will be returned; this is also the case in SelTrans::centerRequest()
@@ -418,9 +416,9 @@ boost::optional<Geom::Point> Selection::center() const {
return first->getCenter();
}
}
- Geom::OptRect bbox = bounds();
+ Geom::OptRect bbox = visualBounds();
if (bbox) {
- return bounds()->midpoint();
+ return bbox->midpoint();
} else {
return boost::optional<Geom::Point>();
}
diff --git a/src/selection.h b/src/selection.h
index 00572a1c5..af0facc3d 100644
--- a/src/selection.h
+++ b/src/selection.h
@@ -244,25 +244,12 @@ public:
guint numberOfParents();
/** @brief Returns the bounding rectangle of the selection */
- NRRect *bounds(NRRect *dest, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const;
- /** @brief Returns the bounding rectangle of the selection */
- Geom::OptRect bounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const;
-
- /**
- * @brief Returns the bounding rectangle of the selection
- *
- * Gives the coordinates in internal format, does not match onscreen guides.
- * (0,0 is the upper left corner, not the lower left corner)
- */
- NRRect *boundsInDocument(NRRect *dest, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const;
+ Geom::OptRect bounds(SPItem::BBoxType type) const;
+ Geom::OptRect visualBounds() const;
+ Geom::OptRect geometricBounds() const;
- /**
- * @brief Returns the bounding rectangle of the selection
- *
- * Gives the coordinates in internal format, does not match onscreen guides.
- * (0,0 is the upper left corner, not the lower left corner)
- */
- Geom::OptRect boundsInDocument(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const;
+ /// Returns the bounding rectangle of the selectionin document coordinates.
+ Geom::OptRect documentBounds(SPItem::BBoxType type) const;
/**
* @brief Returns the rotation/skew center of the selection
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 3a204a49e..19c09902b 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -90,7 +90,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) :
_grabbed(false),
_show_handles(true),
_bbox(),
- _approximate_bbox(),
+ _visual_bbox(),
_absolute_affine(Geom::Scale(1,1)),
_opposite(Geom::Point(0,0)),
_opposite_for_specpoints(Geom::Point(0,0)),
@@ -104,7 +104,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) :
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int prefs_bbox = prefs->getBool("/tools/bounding_box");
_snap_bbox_type = !prefs_bbox ?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
g_return_if_fail(desktop != NULL);
@@ -279,8 +279,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
// First, determine the bounding box
_bbox = selection->bounds(_snap_bbox_type);
- _approximate_bbox = selection->bounds(SPItem::APPROXIMATE_BBOX); // Used for correctly scaling the strokewidth
- _geometric_bbox = selection->bounds(SPItem::GEOMETRIC_BBOX);
+ _visual_bbox = selection->visualBounds(); // Used for correctly scaling the strokewidth
+ _geometric_bbox = selection->geometricBounds();
_point = p;
if (_geometric_bbox) {
@@ -336,7 +336,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
// More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl
// (see the comment a few lines above). In that case we will use the bbox of the selection as a whole
for (unsigned i = 0; i < _items.size(); i++) {
- getBBoxPoints(_items[i]->getBboxDesktop(_snap_bbox_type), &_bbox_points_for_translating, false, c, emp, mp);
+ Geom::OptRect b = _items[i]->desktopBounds(_snap_bbox_type);
+ getBBoxPoints(b, &_bbox_points_for_translating, false, c, emp, mp);
}
} else {
_bbox_points_for_translating = _bbox_points; // use the bbox points of the selection as a whole
@@ -696,7 +697,7 @@ void Inkscape::SelTrans::_updateVolatileState()
//Update the bboxes
_bbox = selection->bounds(_snap_bbox_type);
- _approximate_bbox = selection->bounds(SPItem::APPROXIMATE_BBOX);
+ _visual_bbox = selection->visualBounds();
if (!_bbox) {
_empty = true;
@@ -898,8 +899,7 @@ void Inkscape::SelTrans::_selChanged(Inkscape::Selection */*selection*/)
// reread in case it changed on the fly:
int prefs_bbox = prefs->getBool("/tools/bounding_box");
_snap_bbox_type = !prefs_bbox ?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
- //SPItem::APPROXIMATE_BBOX will be replaced by SPItem::VISUAL_BBOX, as soon as the latter is implemented properly
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
_updateVolatileState();
_current_relative_affine.setIdentity();
@@ -1213,7 +1213,8 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P
SnapManager &m = _desktop->namedview->snap_manager;
m.setup(_desktop, false, _items_const);
- Inkscape::Snapper::SnapConstraint const constraint(component_vectors[dim_b]);
+ Geom::Point cvec; cvec[dim_b] = 1.;
+ Inkscape::Snapper::SnapConstraint const constraint(cvec);
// When skewing, we cannot snap the corners of the bounding box, see the comment in "constrainedSnapSkew" for details
Geom::Point const s(skew[dim_a], scale[dim_a]);
Inkscape::SnappedPoint sn = m.constrainedSnapSkew(_snap_points, _point, constraint, s, _origin, Geom::Dim2(dim_b));
@@ -1475,14 +1476,15 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state)
// the constraint-line once. The constraint lines are parallel, but might not be colinear.
// Therefore we will have to set the point through which the constraint-line runs
// individually for each point to be snapped; this will be handled however by _snapTransformed()
+ Geom::Point cvec; cvec[dim] = 1.;
s.push_back(m.constrainedSnapTranslate(_bbox_points_for_translating,
_point,
- Inkscape::Snapper::SnapConstraint(component_vectors[dim]),
+ Inkscape::Snapper::SnapConstraint(cvec),
dxy));
s.push_back(m.constrainedSnapTranslate(_snap_points,
_point,
- Inkscape::Snapper::SnapConstraint(component_vectors[dim]),
+ Inkscape::Snapper::SnapConstraint(cvec),
dxy));
} else { // !control
@@ -1602,8 +1604,8 @@ Geom::Scale Inkscape::calcScaleFactors(Geom::Point const &initial_point, Geom::P
Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_scale)
{
Geom::Affine abs_affine = Geom::Translate(-_origin) * Geom::Affine(default_scale) * Geom::Translate(_origin);
- Geom::Point new_bbox_min = _approximate_bbox->min() * abs_affine;
- Geom::Point new_bbox_max = _approximate_bbox->max() * abs_affine;
+ Geom::Point new_bbox_min = _visual_bbox->min() * abs_affine;
+ Geom::Point new_bbox_max = _visual_bbox->max() * abs_affine;
bool transform_stroke = false;
gdouble strokewidth = 0;
@@ -1614,7 +1616,7 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_
strokewidth = _strokewidth;
}
- _absolute_affine = get_scale_transform_with_uniform_stroke (*_approximate_bbox, strokewidth, transform_stroke,
+ _absolute_affine = get_scale_transform_with_uniform_stroke (*_visual_bbox, strokewidth, transform_stroke,
new_bbox_min[Geom::X], new_bbox_min[Geom::Y], new_bbox_max[Geom::X], new_bbox_max[Geom::Y]);
// return the new handle position
diff --git a/src/seltrans.h b/src/seltrans.h
index dd890ee9b..9d14fda26 100644
--- a/src/seltrans.h
+++ b/src/seltrans.h
@@ -136,7 +136,7 @@ private:
SPItem::BBoxType _snap_bbox_type;
Geom::OptRect _bbox;
- Geom::OptRect _approximate_bbox;
+ Geom::OptRect _visual_bbox;
Geom::OptRect _geometric_bbox;
gdouble _strokewidth;
diff --git a/src/snap.cpp b/src/snap.cpp
index 5779e59b0..9020b82a3 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -734,7 +734,8 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
Geom::Coord r = Geom::L2(b); // the radius of the circular constraint
dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, b, r);
} else if (transformation_type == STRETCH) { // when non-uniform stretching {
- dedicated_constraint = Inkscape::Snapper::SnapConstraint((*i).getPoint(), component_vectors[dim]);
+ Geom::Point cvec; cvec[dim] = 1.;
+ dedicated_constraint = Inkscape::Snapper::SnapConstraint((*i).getPoint(), cvec);
} else if (transformation_type == TRANSLATE) {
// When doing a constrained translation, all points will move in the same direction, i.e.
// either horizontally or vertically. The lines along which they move are therefore all
@@ -751,7 +752,8 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
// When scaling, a point aligned either horizontally or vertically with the origin can only
// move in that specific direction; therefore it should only snap in that direction, otherwise
// we will get snapped points with an invalid transformation
- dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, component_vectors[c1]);
+ Geom::Point cvec; cvec[c1] = 1.;
+ dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, cvec);
snapped_point = constrainedSnap(*j, dedicated_constraint, bbox);
} else {
// If we have a collection of SnapCandidatePoints, with mixed constrained snapping and free snapping
diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp
index 0b3320e59..2213443a5 100644
--- a/src/sp-clippath.cpp
+++ b/src/sp-clippath.cpp
@@ -34,7 +34,7 @@ struct SPClipPathView {
SPClipPathView *next;
unsigned int key;
Inkscape::DrawingItem *arenaitem;
- NRRect bbox;
+ Geom::OptRect bbox;
};
SPClipPathView *sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem);
@@ -193,10 +193,9 @@ void SPClipPath::update(SPObject *object, SPCtx *ctx, guint flags)
SPClipPath *cp = SP_CLIPPATH(object);
for (SPClipPathView *v = cp->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
- if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) {
- Geom::Affine t(Geom::Scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0));
- t[4] = v->bbox.x0;
- t[5] = v->bbox.y0;
+ if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) {
+ Geom::Affine t = Geom::Scale(v->bbox->dimensions());
+ t.setTranslation(v->bbox->min());
g->setChildTransform(t);
} else {
g->setChildTransform(Geom::identity());
@@ -257,10 +256,9 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int
}
}
- if (clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) {
- Geom::Affine t(Geom::Scale(display->bbox.x1 - display->bbox.x0, display->bbox.y1 - display->bbox.y0));
- t[4] = display->bbox.x0;
- t[5] = display->bbox.y0;
+ if (clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && display->bbox) {
+ Geom::Affine t = Geom::Scale(display->bbox->dimensions());
+ t.setTranslation(display->bbox->min());
ai->setChildTransform(t);
}
ai->setStyle(this->style);
@@ -287,42 +285,26 @@ void SPClipPath::hide(unsigned int key)
g_assert_not_reached();
}
-void SPClipPath::setBBox(unsigned int key, NRRect *bbox)
+void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox)
{
for (SPClipPathView *v = display; v != NULL; v = v->next) {
if (v->key == key) {
- if (!Geom::are_near(v->bbox.x0, bbox->x0) ||
- !Geom::are_near(v->bbox.y0, bbox->y0) ||
- !Geom::are_near(v->bbox.x1, bbox->x1) ||
- !Geom::are_near(v->bbox.y1, bbox->y1)) {
- v->bbox = *bbox;
- }
+ v->bbox = bbox;
break;
}
}
}
-void SPClipPath::getBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/)
+Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform)
{
SPObject *i = 0;
- for (i = firstChild(); i && !SP_IS_ITEM(i); i = i->getNext()) {
- }
- if (!i) {
- return;
- }
-
- SP_ITEM(i)->invoke_bbox_full( bbox, Geom::Affine(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE);
- SPObject *i_start = i;
-
- while (i != NULL) {
- if (i != i_start) {
- NRRect i_box;
- SP_ITEM(i)->invoke_bbox_full( &i_box, Geom::Affine(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE);
- nr_rect_d_union (bbox, bbox, &i_box);
- }
- i = i->getNext();
- for (; i && !SP_IS_ITEM(i); i = i->getNext()){};
+ Geom::OptRect bbox;
+ for (i = firstChild(); i; i = i->getNext()) {
+ if (!SP_IS_ITEM(i)) continue;
+ Geom::OptRect tmp = SP_ITEM(i)->geometricBounds(Geom::Affine(SP_ITEM(i)->transform) * transform);
+ bbox.unionWith(tmp);
}
+ return bbox;
}
/* ClipPath views */
@@ -335,8 +317,7 @@ sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::D
new_path_view->next = list;
new_path_view->key = key;
new_path_view->arenaitem = arenaitem;
- new_path_view->bbox.x0 = new_path_view->bbox.x1 = 0.0;
- new_path_view->bbox.y0 = new_path_view->bbox.y1 = 0.0;
+ new_path_view->bbox = Geom::OptRect();
return new_path_view;
}
diff --git a/src/sp-clippath.h b/src/sp-clippath.h
index 11817eb77..4084b89d8 100644
--- a/src/sp-clippath.h
+++ b/src/sp-clippath.h
@@ -24,7 +24,6 @@
class SPClipPathView;
#include "display/display-forward.h"
-#include "libnr/nr-forward.h"
#include "sp-object-group.h"
#include "uri-references.h"
#include "xml/node.h"
@@ -43,8 +42,8 @@ public:
Inkscape::DrawingItem *show(Inkscape::Drawing &drawing, unsigned int key);
void hide(unsigned int key);
- void setBBox(unsigned int key, NRRect *bbox);
- void getBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+ void setBBox(unsigned int key, Geom::OptRect const &bbox);
+ Geom::OptRect geometricBounds(Geom::Affine const &transform);
private:
static void init(SPClipPath *clippath);
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index 99189da45..ba100a1d7 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -140,19 +140,18 @@ sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags)
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
SPGenericEllipse *ellipse = (SPGenericEllipse *) object;
SPStyle const *style = object->style;
- Geom::OptRect viewbox = ((SPItemCtx const *) ctx)->vp;
- if (viewbox) {
- double const dx = viewbox->width();
- double const dy = viewbox->height();
- double const dr = sqrt(dx*dx + dy*dy)/sqrt(2);
- double const em = style->font_size.computed;
- double const ex = em * 0.5; // fixme: get from pango or libnrtype
- ellipse->cx.update(em, ex, dx);
- ellipse->cy.update(em, ex, dy);
- ellipse->rx.update(em, ex, dr);
- ellipse->ry.update(em, ex, dr);
- static_cast<SPShape *>(object)->setShape();
- }
+ Geom::Rect const &viewbox = ((SPItemCtx const *) ctx)->viewport;
+
+ double const dx = viewbox.width();
+ double const dy = viewbox.height();
+ double const dr = sqrt(dx*dx + dy*dy)/sqrt(2);
+ double const em = style->font_size.computed;
+ double const ex = em * 0.5; // fixme: get from pango or libnrtype
+ ellipse->cx.update(em, ex, dx);
+ ellipse->cy.update(em, ex, dy);
+ ellipse->rx.update(em, ex, dr);
+ ellipse->ry.update(em, ex, dr);
+ static_cast<SPShape *>(object)->setShape();
}
if (((SPObjectClass *) ge_parent_class)->update)
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index ea8079bba..bd73a65c9 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -46,7 +46,7 @@ static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::D
static void sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
static void sp_flowtext_set(SPObject *object, unsigned key, gchar const *value);
-static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_flowtext_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx);
static gchar *sp_flowtext_description(SPItem *item);
static void sp_flowtext_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
@@ -176,20 +176,19 @@ static void sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags)
group->rebuildLayout();
- NRRect paintbox;
- group->invoke_bbox( &paintbox, Geom::identity(), TRUE);
+ Geom::OptRect pbox = group->geometricBounds();
for (SPItemView *v = group->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
group->_clearFlow(g);
g->setStyle(object->style);
// pass the bbox of the flowtext object as paintbox (used for paintserver fills)
- group->layout.show(g, &paintbox);
+ group->layout.show(g, pbox);
}
}
static void sp_flowtext_modified(SPObject *object, guint flags)
{
- SPObject *ft = SP_FLOWTEXT (object);
+ SPObject *ft = object;
SPObject *region = NULL;
if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
@@ -198,13 +197,12 @@ static void sp_flowtext_modified(SPObject *object, guint flags)
// FIXME: the below stanza is copied over from sp_text_modified, consider factoring it out
if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
SPFlowtext *text = SP_FLOWTEXT(object);
- NRRect paintbox;
- text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
+ Geom::OptRect pbox = text->geometricBounds();
for (SPItemView* v = text->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
text->_clearFlow(g);
g->setStyle(object->style);
- text->layout.show(g, &paintbox);
+ text->layout.show(g, pbox);
}
}
@@ -329,53 +327,33 @@ static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::D
return repr;
}
-static void
-sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/)
+static Geom::OptRect
+sp_flowtext_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type)
{
SPFlowtext *group = SP_FLOWTEXT(item);
- group->layout.getBoundingBox(bbox, transform);
+ Geom::OptRect bbox = group->layout.bounds(transform);
// Add stroke width
- SPStyle* style = item->style;
- if ( !style->stroke.isNone() ) {
- double const scale = transform.descrim();
- if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
- double const width = MAX(0.125, style->stroke_width.computed * scale);
- if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
- bbox->x0-=0.5*width;
- bbox->x1+=0.5*width;
- bbox->y0-=0.5*width;
- bbox->y1+=0.5*width;
- }
- }
+ // FIXME this code is incorrect
+ if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) {
+ double scale = transform.descrim();
+ bbox->expandBy(0.5 * item->style->stroke_width.computed * scale);
}
+ return bbox;
}
static void
sp_flowtext_print(SPItem *item, SPPrintContext *ctx)
{
SPFlowtext *group = SP_FLOWTEXT(item);
+ Geom::OptRect pbox, bbox, dbox;
- NRRect pbox;
- item->invoke_bbox( &pbox, Geom::identity(), TRUE);
- NRRect bbox;
- Geom::OptRect bbox_maybe = item->getBboxDesktop();
- if (!bbox_maybe) {
- return;
- }
- bbox.x0 = bbox_maybe->min()[Geom::X];
- bbox.y0 = bbox_maybe->min()[Geom::Y];
- bbox.x1 = bbox_maybe->max()[Geom::X];
- bbox.y1 = bbox_maybe->max()[Geom::Y];
-
- NRRect dbox;
- dbox.x0 = 0.0;
- dbox.y0 = 0.0;
- dbox.x1 = item->document->getWidth();
- dbox.y1 = item->document->getHeight();
+ pbox = item->geometricBounds();
+ bbox = item->desktopVisualBounds();
+ dbox = Geom::Rect::from_xywh(Geom::Point(0,0), item->document->getDimensions());
Geom::Affine const ctm (item->i2dt_affine());
- group->layout.print(ctx, &pbox, &dbox, &bbox, ctm);
+ group->layout.print(ctx, pbox, dbox, bbox, ctm);
}
@@ -417,9 +395,8 @@ sp_flowtext_show(SPItem *item, Inkscape::Drawing &drawing, unsigned/* key*/, uns
flowed->setStyle(group->style);
// pass the bbox of the flowtext object as paintbox (used for paintserver fills)
- NRRect paintbox;
- item->invoke_bbox( &paintbox, Geom::identity(), TRUE);
- group->layout.show(flowed, &paintbox);
+ Geom::OptRect bbox = group->geometricBounds();
+ group->layout.show(flowed, bbox);
return flowed;
}
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index 3aa14dc45..94ad0bb25 100644
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
@@ -1155,7 +1155,7 @@ static void sp_lineargradient_build(SPObject *object,
static void sp_lineargradient_set(SPObject *object, unsigned key, gchar const *value);
static Inkscape::XML::Node *sp_lineargradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr,
guint flags);
-static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity);
+static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity);
static SPGradientClass *lg_parent_class;
@@ -1318,7 +1318,7 @@ static void sp_radialgradient_build(SPObject *object,
static void sp_radialgradient_set(SPObject *object, unsigned key, gchar const *value);
static Inkscape::XML::Node *sp_radialgradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr,
guint flags);
-static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity);
+static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity);
static SPGradientClass *rg_parent_class;
@@ -1494,7 +1494,7 @@ sp_radialgradient_set_position(SPRadialGradient *rg,
static void
sp_gradient_pattern_common_setup(cairo_pattern_t *cp,
SPGradient *gr,
- NRRect const *bbox,
+ Geom::OptRect const &bbox,
double opacity)
{
// set spread type
@@ -1523,7 +1523,7 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp,
// set pattern matrix
Geom::Affine gs2user = gr->gradientTransform;
if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
- Geom::Affine bbox2user(bbox->x1 - bbox->x0, 0, 0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0);
+ Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top());
gs2user *= bbox2user;
}
ink_cairo_pattern_set_matrix(cp, gs2user.inverse());
@@ -1532,7 +1532,7 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp,
static cairo_pattern_t *
sp_radialgradient_create_pattern(SPPaintServer *ps,
cairo_t */* ct */,
- NRRect const *bbox,
+ Geom::OptRect const &bbox,
double opacity)
{
SPRadialGradient *rg = SP_RADIALGRADIENT(ps);
@@ -1552,7 +1552,7 @@ sp_radialgradient_create_pattern(SPPaintServer *ps,
static cairo_pattern_t *
sp_lineargradient_create_pattern(SPPaintServer *ps,
cairo_t */* ct */,
- NRRect const *bbox,
+ Geom::OptRect const &bbox,
double opacity)
{
SPLinearGradient *lg = SP_LINEARGRADIENT(ps);
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index a06d098d0..5d30800d6 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -116,7 +116,7 @@ static void sp_guide_class_init(SPGuideClass *gc)
static void sp_guide_init(SPGuide *guide)
{
- guide->normal_to_line = component_vectors[Geom::Y];
+ guide->normal_to_line = Geom::Point(0.,1.);
guide->point_on_line = Geom::Point(0.,0.);
guide->color = 0x0000ff7f;
guide->hicolor = 0xff00007f;
@@ -205,9 +205,9 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
{
if (value && !strcmp(value, "horizontal")) {
/* Visual representation of a horizontal line, constrain vertically (y coordinate). */
- guide->normal_to_line = component_vectors[Geom::Y];
+ guide->normal_to_line = Geom::Point(0., 1.);
} else if (value && !strcmp(value, "vertical")) {
- guide->normal_to_line = component_vectors[Geom::X];
+ guide->normal_to_line = Geom::Point(1., 0.);
} else if (value) {
gchar ** strarray = g_strsplit(value, ",", 2);
double newx, newy;
@@ -220,11 +220,11 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
guide->normal_to_line = direction;
} else {
// default to vertical line for bad arguments
- guide->normal_to_line = component_vectors[Geom::X];
+ guide->normal_to_line = Geom::Point(1., 0.);
}
} else {
// default to vertical line for bad arguments
- guide->normal_to_line = component_vectors[Geom::X];
+ guide->normal_to_line = Geom::Point(1., 0.);
}
sp_guide_set_normal(*guide, guide->normal_to_line, false);
}
@@ -493,11 +493,11 @@ char *sp_guide_description(SPGuide const *guide, const bool verbose)
gchar *shortcuts = g_strdup_printf("; %s", _("<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to delete"));
- if ( are_near(guide->normal_to_line, component_vectors[X]) ||
- are_near(guide->normal_to_line, -component_vectors[X]) ) {
+ if ( are_near(guide->normal_to_line, Geom::Point(1., 0.)) ||
+ are_near(guide->normal_to_line, -Geom::Point(1., 0.)) ) {
descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str);
- } else if ( are_near(guide->normal_to_line, component_vectors[Y]) ||
- are_near(guide->normal_to_line, -component_vectors[Y]) ) {
+ } else if ( are_near(guide->normal_to_line, Geom::Point(0., 1.)) ||
+ are_near(guide->normal_to_line, -Geom::Point(0., 1.)) ) {
descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str);
} else {
double const radians = guide->angle();
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index 5f398b10e..1bfcc90e5 100644
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -80,7 +80,7 @@ static void sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags);
static void sp_image_modified (SPObject *object, unsigned int flags);
static Inkscape::XML::Node *sp_image_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-static void sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_image_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static void sp_image_print (SPItem * item, SPPrintContext *ctx);
static gchar * sp_image_description (SPItem * item);
static void sp_image_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
@@ -1062,21 +1062,16 @@ static Inkscape::XML::Node *sp_image_write( SPObject *object, Inkscape::XML::Doc
return repr;
}
-static void sp_image_bbox( SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/ )
+static Geom::OptRect sp_image_bbox( SPItem const *item,Geom::Affine const &transform, SPItem::BBoxType type )
{
SPImage const &image = *SP_IMAGE(item);
+ Geom::OptRect bbox;
if ((image.width.computed > 0.0) && (image.height.computed > 0.0)) {
- double const x0 = image.x.computed;
- double const y0 = image.y.computed;
- double const x1 = x0 + image.width.computed;
- double const y1 = y0 + image.height.computed;
-
- nr_rect_union_pt(bbox, Geom::Point(x0, y0) * transform);
- nr_rect_union_pt(bbox, Geom::Point(x1, y0) * transform);
- nr_rect_union_pt(bbox, Geom::Point(x1, y1) * transform);
- nr_rect_union_pt(bbox, Geom::Point(x0, y1) * transform);
+ bbox = Geom::Rect::from_xywh(image.x.computed, image.y.computed, image.width.computed, image.height.computed);
+ *bbox *= transform;
}
+ return bbox;
}
static void sp_image_print( SPItem *item, SPPrintContext *ctx )
@@ -1100,7 +1095,7 @@ static void sp_image_print( SPItem *item, SPPrintContext *ctx )
Geom::Translate ti(0.0, -1.0);
t = s * tp;
t = ti * t;
- sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, &t, item->style);
+ sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, item->style);
} else { // preserveAspectRatio
double vw = image->width.computed / image->sx;
double vh = image->height.computed / image->sy;
@@ -1121,7 +1116,7 @@ static void sp_image_print( SPItem *item, SPPrintContext *ctx )
Geom::Translate ti(0.0, -1.0);
t = s * tp;
t = ti * t;
- sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, &t, item->style);
+ sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, t, item->style);
}
}
}
@@ -1499,10 +1494,8 @@ static void sp_image_set_curve( SPImage *image )
image->curve = image->curve->unref();
}
} else {
- NRRect rect;
- sp_image_bbox(image, &rect, Geom::identity(), 0);
- Geom::Rect rect2 = *to_2geom(&rect);
- SPCurve *c = SPCurve::new_from_rect(rect2, true);
+ Geom::OptRect rect = sp_image_bbox(image, Geom::identity(), SPItem::VISUAL_BBOX);
+ SPCurve *c = SPCurve::new_from_rect(*rect, true);
if (image->curve) {
image->curve = image->curve->unref();
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index f8ab0460a..ada980b3e 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -65,7 +65,7 @@ static void sp_group_modified (SPObject *object, guint flags);
static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void sp_group_set(SPObject *object, unsigned key, char const *value);
-static void sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_group_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static void sp_group_print (SPItem * item, SPPrintContext *ctx);
static gchar * sp_group_description (SPItem * item);
static Inkscape::DrawingItem *sp_group_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
@@ -274,10 +274,10 @@ static Inkscape::XML::Node * sp_group_write(SPObject *object, Inkscape::XML::Doc
return repr;
}
-static void
-sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags)
+static Geom::OptRect
+sp_group_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type)
{
- SP_GROUP(item)->group->calculateBBox(bbox, transform, flags);
+ return SP_GROUP(item)->group->bounds(type, transform);
}
static void
@@ -696,9 +696,9 @@ void CGroup::onModified(guint flags) {
}
}
-void CGroup::calculateBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const flags) {
-
- Geom::OptRect dummy_bbox;
+Geom::OptRect CGroup::bounds(SPItem::BBoxType type, Geom::Affine const &transform)
+{
+ Geom::OptRect bbox;
GSList *l = _group->childList(false, SPObject::ActionBBox);
while (l) {
@@ -706,12 +706,11 @@ void CGroup::calculateBBox(NRRect *bbox, Geom::Affine const &transform, unsigned
if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) {
SPItem *child = SP_ITEM(o);
Geom::Affine const ct(child->transform * transform);
- child->invoke_bbox_full( dummy_bbox, ct, flags, FALSE);
+ bbox |= child->bounds(type, transform);
}
l = g_slist_remove (l, o);
}
-
- *bbox = NRRect(dummy_bbox);
+ return bbox;
}
void CGroup::onPrint(SPPrintContext *ctx) {
diff --git a/src/sp-item-group.h b/src/sp-item-group.h
index 99f375e44..f56192925 100644
--- a/src/sp-item-group.h
+++ b/src/sp-item-group.h
@@ -69,7 +69,7 @@ public:
virtual void onChildRemoved(Inkscape::XML::Node *child);
virtual void onUpdate(SPCtx *ctx, unsigned int flags);
virtual void onModified(guint flags);
- virtual void calculateBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+ virtual Geom::OptRect bounds(SPItem::BBoxType type, Geom::Affine const &transform);
virtual void onPrint(SPPrintContext *ctx);
virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
virtual gchar *getDescription();
diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp
index 9f166e718..749a32d52 100644
--- a/src/sp-item-transform.cpp
+++ b/src/sp-item-transform.cpp
@@ -39,7 +39,7 @@ sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation)
void
sp_item_scale_rel (SPItem *item, Geom::Scale const &scale)
{
- Geom::OptRect bbox = item->getBboxDesktop();
+ Geom::OptRect bbox = item->desktopVisualBounds();
if (bbox) {
Geom::Translate const s(bbox->midpoint()); // use getCenter?
item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s);
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 07ce73c4b..c0c23ba8b 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -25,7 +25,6 @@
# include "config.h"
#endif
-
#include "sp-item.h"
#include "svg/svg.h"
#include "print.h"
@@ -60,7 +59,6 @@
#include "sp-title.h"
#include "sp-desc.h"
-#include "libnr/nr-convert2geom.h"
#include "util/find-last-if.h"
#include "util/reverse-list.h"
#include <2geom/rect.h>
@@ -253,7 +251,7 @@ bool SPItem::isExplicitlyHidden() const
* Sets the display CSS property to `hidden' if \a val is true,
* otherwise makes it unset
*/
-void SPItem::setExplicitlyHidden(bool const val) {
+void SPItem::setExplicitlyHidden(bool val) {
style->display.set = val;
style->display.value = ( val ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE );
style->display.computed = style->display.value;
@@ -263,17 +261,17 @@ void SPItem::setExplicitlyHidden(bool const val) {
/**
* Sets the transform_center_x and transform_center_y properties to retain the rotation centre
*/
-void SPItem::setCenter(Geom::Point object_centre) {
- // for getBounds() to work
+void SPItem::setCenter(Geom::Point const &object_centre) {
document->ensureUpToDate();
- Geom::OptRect bbox = getBounds(i2dt_affine());
+ // FIXME this is seriously wrong
+ Geom::OptRect bbox = desktopGeometricBounds();
if (bbox) {
transform_center_x = object_centre[Geom::X] - bbox->midpoint()[Geom::X];
- if (fabs(transform_center_x) < 1e-5) // rounding error
+ if (Geom::are_near(transform_center_x, 0)) // rounding error
transform_center_x = 0;
transform_center_y = object_centre[Geom::Y] - bbox->midpoint()[Geom::Y];
- if (fabs(transform_center_y) < 1e-5) // rounding error
+ if (Geom::are_near(transform_center_y, 0)) // rounding error
transform_center_y = 0;
}
}
@@ -289,10 +287,10 @@ bool SPItem::isCenterSet() {
}
Geom::Point SPItem::getCenter() const {
- // for getBounds() to work
document->ensureUpToDate();
- Geom::OptRect bbox = getBounds(i2dt_affine());
+ // FIXME this is seriously wrong
+ Geom::OptRect bbox = desktopGeometricBounds();
if (bbox) {
return bbox->midpoint() + Geom::Point (transform_center_x, transform_center_y);
} else {
@@ -515,8 +513,7 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item)
}
}
if (SP_IS_CLIPPATH(clip)) {
- NRRect bbox;
- item->invoke_bbox( &bbox, Geom::identity(), TRUE);
+ Geom::OptRect bbox = item->geometricBounds();
for (SPItemView *v = item->display; v != NULL; v = v->next) {
if (!v->arenaitem->key()) {
v->arenaitem->setKey(SPItem::display_key_new(3));
@@ -525,7 +522,7 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item)
v->arenaitem->drawing(),
v->arenaitem->key());
v->arenaitem->setClip(ai);
- SP_CLIPPATH(clip)->setBBox(v->arenaitem->key(), &bbox);
+ SP_CLIPPATH(clip)->setBBox(v->arenaitem->key(), bbox);
clip->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
@@ -540,8 +537,7 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item)
}
}
if (SP_IS_MASK(mask)) {
- NRRect bbox;
- item->invoke_bbox( &bbox, Geom::identity(), TRUE);
+ Geom::OptRect bbox = item->geometricBounds();
for (SPItemView *v = item->display; v != NULL; v = v->next) {
if (!v->arenaitem->key()) {
v->arenaitem->setKey(SPItem::display_key_new(3));
@@ -550,7 +546,7 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item)
v->arenaitem->drawing(),
v->arenaitem->key());
v->arenaitem->setMask(ai);
- sp_mask_set_bbox(SP_MASK(mask), v->arenaitem->key(), &bbox);
+ sp_mask_set_bbox(SP_MASK(mask), v->arenaitem->key(), bbox);
mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
@@ -575,16 +571,15 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags)
SPMask *mask = item->mask_ref ? item->mask_ref->getObject() : NULL;
if ( clip_path || mask ) {
- NRRect bbox;
- item->invoke_bbox( &bbox, Geom::identity(), TRUE);
+ Geom::OptRect bbox = item->geometricBounds();
if (clip_path) {
for (SPItemView *v = item->display; v != NULL; v = v->next) {
- clip_path->setBBox(v->arenaitem->key(), &bbox);
+ clip_path->setBBox(v->arenaitem->key(), bbox);
}
}
if (mask) {
for (SPItemView *v = item->display; v != NULL; v = v->next) {
- sp_mask_set_bbox(mask, v->arenaitem->key(), &bbox);
+ sp_mask_set_bbox(mask, v->arenaitem->key(), bbox);
}
}
}
@@ -599,8 +594,7 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags)
/* Update bounding box data used by filters */
if (item->style->filter.set && item->display) {
- Geom::OptRect item_bbox;
- item->invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect item_bbox = item->geometricBounds();
SPItemView *itemview = item->display;
do {
@@ -677,169 +671,132 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML
return repr;
}
-/**
- * \return There is no guarantee that the return value will contain a rectangle.
- If this item does not have a boundingbox, it might well be empty.
- */
-Geom::OptRect SPItem::getBounds(Geom::Affine const &transform,
- SPItem::BBoxType type,
- unsigned int /*dkey*/) const
-{
- Geom::OptRect r;
- invoke_bbox_full( r, transform, type, TRUE);
- return r;
-}
-
-void SPItem::invoke_bbox( Geom::OptRect &bbox, Geom::Affine const &transform, unsigned const clear, SPItem::BBoxType type)
+/** @brief Get item's geometric bounding box in this item's coordinate system.
+ * The geometric bounding box includes only the path, disregarding all style attributes. */
+Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const
{
- invoke_bbox_full( bbox, transform, type, clear);
-}
-
-// DEPRECATED to phase out the use of NRRect in favor of Geom::OptRect
-void SPItem::invoke_bbox( NRRect *bbox, Geom::Affine const &transform, unsigned const clear, SPItem::BBoxType type)
-{
- invoke_bbox_full( bbox, transform, type, clear);
+ Geom::OptRect bbox;
+ // call the subclass method
+ if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
+ bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::GEOMETRIC_BBOX);
+ }
+ return bbox;
}
-/** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and
- * unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the
- * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups,
- * clones), in turn, call this function in their bbox methods.
- * \retval bbox Note that there is no guarantee that bbox will contain a rectangle when the
- * function returns. If this item does not have a boundingbox, this might well be empty.
- */
-void SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Affine const &transform, unsigned const flags, unsigned const clear) const
+/** @brief Get item's visual bounding box in this item's coordinate system.
+ * The visual bounding box includes the stroke and the filter region. */
+Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const
{
- if (clear) {
- bbox = Geom::OptRect();
- }
-
- // TODO: replace NRRect by Geom::Rect, for all SPItemClasses, and for SP_CLIPPATH
+ using Geom::X;
+ using Geom::Y;
- NRRect temp_bbox;
- temp_bbox.x0 = temp_bbox.y0 = Geom::infinity();
- temp_bbox.x1 = temp_bbox.y1 = -Geom::infinity();
+ Geom::OptRect bbox;
- // call the subclass method
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
- ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, &temp_bbox, transform, flags);
- }
-
- // unless this is geometric bbox, extend by filter area and crop the bbox by clip path, if any
- if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX) {
- if ( style && style->filter.href) {
- SPObject *filter = style->getFilter();
- if (filter && SP_IS_FILTER(filter)) {
- // default filer area per the SVG spec:
- double x = -0.1;
- double y = -0.1;
- double w = 1.2;
- double h = 1.2;
-
- // if area is explicitly set, override:
- if (SP_FILTER(filter)->x._set)
- x = SP_FILTER(filter)->x.computed;
- if (SP_FILTER(filter)->y._set)
- y = SP_FILTER(filter)->y.computed;
- if (SP_FILTER(filter)->width._set)
- w = SP_FILTER(filter)->width.computed;
- if (SP_FILTER(filter)->height._set)
- h = SP_FILTER(filter)->height.computed;
-
- double dx0 = 0;
- double dx1 = 0;
- double dy0 = 0;
- double dy1 = 0;
- if (filter_is_single_gaussian_blur(SP_FILTER(filter))) {
- // if this is a single blur, use 2.4*radius
- // which may be smaller than the default area;
- // see set_filter_area for why it's 2.4
- double r = get_single_gaussian_blur_radius (SP_FILTER(filter));
- dx0 = -2.4 * r;
- dx1 = 2.4 * r;
- dy0 = -2.4 * r;
- dy1 = 2.4 * r;
- } else {
- // otherwise, calculate expansion from relative to absolute units:
- dx0 = x * (temp_bbox.x1 - temp_bbox.x0);
- dx1 = (w + x - 1) * (temp_bbox.x1 - temp_bbox.x0);
- dy0 = y * (temp_bbox.y1 - temp_bbox.y0);
- dy1 = (h + y - 1) * (temp_bbox.y1 - temp_bbox.y0);
- }
+ if ( style && style->filter.href && style->getFilter() && SP_IS_FILTER(style->getFilter())) {
+ // call the subclass method
+ if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
+ bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, Geom::identity(), SPItem::VISUAL_BBOX);
+ }
- // transform the expansions by the item's transform:
- Geom::Affine i2dt(i2dt_affine ());
- dx0 *= i2dt.expansionX();
- dx1 *= i2dt.expansionX();
- dy0 *= i2dt.expansionY();
- dy1 *= i2dt.expansionY();
-
- // expand the bbox
- temp_bbox.x0 += dx0;
- temp_bbox.x1 += dx1;
- temp_bbox.y0 += dy0;
- temp_bbox.y1 += dy1;
- }
+ SPFilter *filter = SP_FILTER(style->getFilter());
+ // default filer area per the SVG spec:
+ SVGLength x, y, w, h;
+ Geom::Point minp, maxp;
+ x.set(SVGLength::PERCENT, -0.10, 0);
+ y.set(SVGLength::PERCENT, -0.10, 0);
+ w.set(SVGLength::PERCENT, 1.20, 0);
+ h.set(SVGLength::PERCENT, 1.20, 0);
+
+ // if area is explicitly set, override:
+ if (filter->x._set)
+ x = filter->x;
+ if (filter->y._set)
+ y = filter->y;
+ if (filter->width._set)
+ w = filter->width;
+ if (filter->height._set)
+ h = filter->height;
+
+ double len_x = bbox ? bbox->width() : 0;
+ double len_y = bbox ? bbox->height() : 0;
+
+ x.update(12, 6, len_x);
+ y.update(12, 6, len_y);
+ w.update(12, 6, len_x);
+ h.update(12, 6, len_y);
+
+ if (filter->filterUnits == SP_FILTER_UNITS_OBJECTBOUNDINGBOX && bbox) {
+ minp[X] = bbox->left() + x.computed * (x.unit == SVGLength::PERCENT ? 1.0 : len_x);
+ maxp[X] = minp[X] + w.computed * (w.unit == SVGLength::PERCENT ? 1.0 : len_x);
+ minp[Y] = bbox->top() + y.computed * (y.unit == SVGLength::PERCENT ? 1.0 : len_y);
+ maxp[Y] = minp[Y] + h.computed * (h.unit == SVGLength::PERCENT ? 1.0 : len_y);
+ } else if (filter->filterUnits == SP_FILTER_UNITS_USERSPACEONUSE) {
+ minp[X] = x.computed;
+ maxp[X] = minp[X] + w.computed;
+ minp[Y] = y.computed;
+ maxp[Y] = minp[Y] + h.computed;
}
- if (clip_ref->getObject()) {
- NRRect b;
- SP_CLIPPATH(clip_ref->getObject())->getBBox(&b, transform, flags);
- nr_rect_d_intersect (&temp_bbox, &temp_bbox, &b);
+ bbox = Geom::OptRect(minp, maxp);
+ *bbox *= transform;
+ } else {
+ // call the subclass method
+ if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
+ bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::VISUAL_BBOX);
}
}
-
- if (temp_bbox.x0 > temp_bbox.x1 || temp_bbox.y0 > temp_bbox.y1) {
- // Either the bbox hasn't been touched by the SPItemClass' bbox method
- // (it still has its initial values, see above: x0 = y0 = Geom::infinity() and x1 = y1 = -Geom::infinity())
- // or it has explicitely been set to be like this (e.g. in sp_shape_bbox)
-
- // When x0 > x1 or y0 > y1, the bbox is considered to be "nothing", although it has not been
- // explicitely defined this way for NRRects (as opposed to Geom::OptRect)
- // So union bbox with nothing = do nothing, just return
- return;
+ if (clip_ref->getObject()) {
+ bbox.intersectWith(SP_CLIPPATH(clip_ref->getObject())->geometricBounds(transform));
}
- // Do not use temp_bbox.upgrade() here, because it uses a test that returns an empty Geom::OptRect()
- // for any rectangle with zero area. The geometrical bbox of for example a vertical line
- // would therefore be translated into empty Geom::OptRect() (see bug https://bugs.launchpad.net/inkscape/+bug/168684)
- Geom::OptRect temp_bbox_new = Geom::Rect(Geom::Point(temp_bbox.x0, temp_bbox.y0), Geom::Point(temp_bbox.x1, temp_bbox.y1));
-
- bbox.unionWith(temp_bbox_new);
+ return bbox;
}
-
-// DEPRECATED to phase out the use of NRRect in favor of Geom::OptRect
-/** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and
- * unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the
- * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups,
- * clones), in turn, call this function in their bbox methods. */
-void SPItem::invoke_bbox_full( NRRect *bbox, Geom::Affine const &transform, unsigned const flags, unsigned const clear)
+Geom::OptRect SPItem::bounds(BBoxType type, Geom::Affine const &transform) const
{
- g_assert(bbox != NULL);
-
- if (clear) {
- bbox->x0 = bbox->y0 = 1e18;
- bbox->x1 = bbox->y1 = -1e18;
- }
-
- NRRect this_bbox;
- this_bbox.x0 = this_bbox.y0 = 1e18;
- this_bbox.x1 = this_bbox.y1 = -1e18;
-
- // call the subclass method
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
- ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, &this_bbox, transform, flags);
+ if (type == GEOMETRIC_BBOX) {
+ return geometricBounds(transform);
+ } else {
+ return visualBounds(transform);
}
+}
- // unless this is geometric bbox, crop the bbox by clip path, if any
- if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && clip_ref->getObject()) {
- NRRect b;
- SP_CLIPPATH(clip_ref->getObject())->getBBox(&b, transform, flags);
- nr_rect_d_intersect (&this_bbox, &this_bbox, &b);
+/** Get item's geometric bbox in document coordinate system.
+ * Document coordinates are the default coordinates of the root element:
+ * the origin is at the top left, X grows to the right and Y grows downwards. */
+Geom::OptRect SPItem::documentGeometricBounds() const
+{
+ return geometricBounds(i2doc_affine());
+}
+/// Get item's visual bbox in document coordinate system.
+Geom::OptRect SPItem::documentVisualBounds() const
+{
+ return visualBounds(i2doc_affine());
+}
+Geom::OptRect SPItem::documentBounds(BBoxType type) const
+{
+ if (type == GEOMETRIC_BBOX) {
+ return documentGeometricBounds();
+ } else {
+ return documentVisualBounds();
}
-
- // if non-empty (with some tolerance - ?) union this_bbox with the bbox we've got passed
- if ( fabs(this_bbox.x1-this_bbox.x0) > -0.00001 && fabs(this_bbox.y1-this_bbox.y0) > -0.00001 ) {
- nr_rect_d_union (bbox, bbox, &this_bbox);
+}
+/** Get item's geometric bbox in desktop coordinate system.
+ * Desktop coordinates should be user defined. Currently they are hardcoded:
+ * origin is at bottom left, X grows to the right and Y grows upwards. */
+Geom::OptRect SPItem::desktopGeometricBounds() const
+{
+ return geometricBounds(i2dt_affine());
+}
+/// Get item's visual bbox in desktop coordinate system.
+Geom::OptRect SPItem::desktopVisualBounds() const
+{
+ return visualBounds(i2dt_affine());
+}
+Geom::OptRect SPItem::desktopBounds(BBoxType type) const
+{
+ if (type == GEOMETRIC_BBOX) {
+ return desktopGeometricBounds();
+ } else {
+ return desktopVisualBounds();
}
}
@@ -864,20 +821,6 @@ unsigned SPItem::pos_in_parent()
return 0;
}
-void SPItem::getBboxDesktop(NRRect *bbox, SPItem::BBoxType type)
-{
- g_assert(bbox != NULL);
-
- invoke_bbox( bbox, i2dt_affine(), TRUE, type);
-}
-
-Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type)
-{
- Geom::OptRect rect = Geom::OptRect();
- invoke_bbox( rect, i2dt_affine(), TRUE, type);
- return rect;
-}
-
void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs)
{
/* This will only be called if the derived class doesn't override this.
@@ -1011,6 +954,8 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned
}
if (ai != NULL) {
+ Geom::OptRect item_bbox = geometricBounds();
+
display = sp_item_view_new_prepend(display, this, flags, key, ai);
ai->setTransform(transform);
ai->setOpacity(SP_SCALE24_TO_FLOAT(style->opacity.value));
@@ -1029,9 +974,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned
ai->setClip(ac);
// Update bbox, in case the clip uses bbox units
- NRRect bbox;
- invoke_bbox( &bbox, Geom::identity(), TRUE);
- SP_CLIPPATH(cp)->setBBox(clip_key, &bbox);
+ SP_CLIPPATH(cp)->setBBox(clip_key, item_bbox);
cp->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
if (mask_ref->getObject()) {
@@ -1047,14 +990,10 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned
ai->setMask(ac);
// Update bbox, in case the mask uses bbox units
- NRRect bbox;
- invoke_bbox( &bbox, Geom::identity(), TRUE);
- sp_mask_set_bbox(SP_MASK(mask), mask_key, &bbox);
+ sp_mask_set_bbox(SP_MASK(mask), mask_key, item_bbox);
mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
ai->setData(this);
- Geom::OptRect item_bbox;
- invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX);
ai->setItemBounds(item_bbox);
}
@@ -1361,7 +1300,7 @@ gint SPItem::emitEvent(SPEvent &event)
*/
void SPItem::set_item_transform(Geom::Affine const &transform_matrix)
{
- if (!matrix_equalp(transform_matrix, transform, NR_EPSILON)) {
+ if (!Geom::are_near(transform_matrix, transform, 1e-18)) {
transform = transform_matrix;
/* The SP_OBJECT_USER_MODIFIED_FLAG_B is used to mark the fact that it's only a
transformation. It's apparently not used anywhere else. */
@@ -1544,10 +1483,8 @@ SPItem *sp_item_first_item_child(SPObject *obj)
void SPItem::convert_to_guides() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int prefs_bbox = prefs->getInt("/tools/bounding_box", 0);
- SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
- Geom::OptRect bbox = getBboxDesktop(bbox_type);
+ Geom::OptRect bbox = (prefs_bbox == 0) ? desktopVisualBounds() : desktopGeometricBounds();
if (!bbox) {
g_warning ("Cannot determine item's bounding box during conversion to guides.\n");
return;
diff --git a/src/sp-item.h b/src/sp-item.h
index 633deb508..b827f6555 100644
--- a/src/sp-item.h
+++ b/src/sp-item.h
@@ -19,14 +19,13 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <vector>
+#include <2geom/forward.h>
+#include <2geom/affine.h>
+#include <2geom/rect.h>
#include "display/display-forward.h"
#include "sp-object.h"
-#include <2geom/affine.h>
-#include <libnr/nr-rect.h>
-#include <2geom/forward.h>
-#include <libnr/nr-convert2geom.h>
-#include <snap-preferences.h>
+#include "snap-preferences.h"
#include "snap-candidate.h"
class SPGuideConstraint;
@@ -88,7 +87,7 @@ public:
/** Item to document transformation */
Geom::Affine i2doc;
/** Viewport size */
- NRRect vp;
+ Geom::Rect viewport;
/** Item to viewport transformation */
Geom::Affine i2vp;
};
@@ -112,7 +111,7 @@ public:
// includes only the bare path bbox, no stroke, no nothing
GEOMETRIC_BBOX,
// includes everything: correctly done stroke (with proper miters and caps), markers, filter margins (e.g. blur)
- RENDERING_BBOX
+ VISUAL_BBOX
};
unsigned int sensitive : 1;
@@ -151,7 +150,7 @@ public:
void setExplicitlyHidden(bool val);
- void setCenter(Geom::Point object_centre);
+ void setCenter(Geom::Point const &object_centre);
void unsetCenter();
bool isCenterSet();
Geom::Point getCenter() const;
@@ -167,15 +166,19 @@ public:
void raiseToTop();
void lowerToBottom();
- Geom::OptRect getBounds(Geom::Affine const &transform, BBoxType type=APPROXIMATE_BBOX, unsigned int dkey=0) const;
-
sigc::connection connectTransformed(sigc::slot<void, Geom::Affine const *, SPItem *> slot) {
return _transformed_signal.connect(slot);
}
- void invoke_bbox( Geom::OptRect &bbox, Geom::Affine const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
- void invoke_bbox( NRRect *bbox, Geom::Affine const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated));
- void invoke_bbox_full( Geom::OptRect &bbox, Geom::Affine const &transform, unsigned const flags, unsigned const clear) const;
- void invoke_bbox_full( NRRect *bbox, Geom::Affine const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated));
+
+ Geom::OptRect geometricBounds(Geom::Affine const &transform = Geom::identity()) const;
+ Geom::OptRect visualBounds(Geom::Affine const &transform = Geom::identity()) const;
+ Geom::OptRect bounds(BBoxType type, Geom::Affine const &transform = Geom::identity()) const;
+ Geom::OptRect documentGeometricBounds() const;
+ Geom::OptRect documentVisualBounds() const;
+ Geom::OptRect documentBounds(BBoxType type) const;
+ Geom::OptRect desktopGeometricBounds() const;
+ Geom::OptRect desktopVisualBounds() const;
+ Geom::OptRect desktopBounds(BBoxType type) const;
unsigned pos_in_parent();
gchar *description();
@@ -195,8 +198,7 @@ public:
void convert_item_to_guides();
gint emitEvent (SPEvent &event);
Inkscape::DrawingItem *get_arenaitem(unsigned int key);
- void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated));
- Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
+
Geom::Affine i2doc_affine() const;
Geom::Affine i2dt_affine() const;
void set_i2d_affine(Geom::Affine const &transform);
@@ -237,7 +239,7 @@ public:
SPObjectClass parent_class;
/** BBox union in given coordinate system */
- void (* bbox) (SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+ Geom::OptRect (* bbox) (SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
/** Printing method. Assumes ctm is set to item affine matrix */
/* \todo Think about it, and maybe implement generic export method instead (Lauris) */
diff --git a/src/sp-line.cpp b/src/sp-line.cpp
index d3faf2299..06604a1d6 100644
--- a/src/sp-line.cpp
+++ b/src/sp-line.cpp
@@ -127,8 +127,8 @@ void SPLine::update(SPObject *object, SPCtx *ctx, guint flags)
SPStyle const *style = object->style;
SPItemCtx const *ictx = (SPItemCtx const *) ctx;
- double const w = (ictx->vp.x1 - ictx->vp.x0);
- double const h = (ictx->vp.y1 - ictx->vp.y0);
+ 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);
diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp
index f23172a17..f955e5428 100644
--- a/src/sp-mask.cpp
+++ b/src/sp-mask.cpp
@@ -31,7 +31,7 @@ struct SPMaskView {
SPMaskView *next;
unsigned int key;
Inkscape::DrawingItem *arenaitem;
- NRRect bbox;
+ Geom::OptRect bbox;
};
static void sp_mask_class_init (SPMaskClass *klass);
@@ -216,10 +216,9 @@ static void sp_mask_update(SPObject *object, SPCtx *ctx, guint flags)
SPMask *mask = SP_MASK(object);
for (SPMaskView *v = mask->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
- if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) {
- Geom::Affine t(Geom::Scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0));
- t[4] = v->bbox.x0;
- t[5] = v->bbox.y0;
+ if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) {
+ Geom::Affine t = Geom::Scale(v->bbox->dimensions());
+ t.setTranslation(v->bbox->min());
g->setChildTransform(t);
} else {
g->setChildTransform(Geom::identity());
@@ -314,11 +313,10 @@ Inkscape::DrawingItem *sp_mask_show(SPMask *mask, Inkscape::Drawing &drawing, un
}
}
- if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) {
- Geom::Affine t(Geom::Scale(mask->display->bbox.x1 - mask->display->bbox.x0, mask->display->bbox.y1 - mask->display->bbox.y0));
- t[4] = mask->display->bbox.x0;
- t[5] = mask->display->bbox.y0;
- ai->setChildTransform(t);
+ if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && mask->display->bbox) {
+ Geom::Affine t = Geom::Scale(mask->display->bbox->dimensions());
+ t.setTranslation(mask->display->bbox->min());
+ ai->setChildTransform(t);
}
return ai;
@@ -347,17 +345,12 @@ void sp_mask_hide(SPMask *cp, unsigned int key)
}
void
-sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox)
+sp_mask_set_bbox (SPMask *mask, unsigned int key, Geom::OptRect const &bbox)
{
for (SPMaskView *v = mask->display; v != NULL; v = v->next) {
if (v->key == key) {
- if (!Geom::are_near(v->bbox.x0, bbox->x0) ||
- !Geom::are_near(v->bbox.y0, bbox->y0) ||
- !Geom::are_near(v->bbox.x1, bbox->x1) ||
- !Geom::are_near(v->bbox.y1, bbox->y1)) {
- v->bbox = *bbox;
- }
- break;
+ v->bbox = bbox;
+ break;
}
}
}
@@ -372,8 +365,7 @@ sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingI
new_mask_view->next = list;
new_mask_view->key = key;
new_mask_view->arenaitem = arenaitem;
- new_mask_view->bbox.x0 = new_mask_view->bbox.x1 = 0.0;
- new_mask_view->bbox.y0 = new_mask_view->bbox.y1 = 0.0;
+ new_mask_view->bbox = Geom::OptRect();
return new_mask_view;
}
diff --git a/src/sp-mask.h b/src/sp-mask.h
index b1048e6be..10b42ca1e 100644
--- a/src/sp-mask.h
+++ b/src/sp-mask.h
@@ -13,6 +13,12 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <2geom/rect.h>
+#include "display/display-forward.h"
+#include "sp-object-group.h"
+#include "uri-references.h"
+#include "xml/node.h"
+
#define SP_TYPE_MASK (sp_mask_get_type ())
#define SP_MASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_MASK, SPMask))
#define SP_MASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_MASK, SPMaskClass))
@@ -23,12 +29,6 @@ class SPMask;
class SPMaskClass;
class SPMaskView;
-#include "display/display-forward.h"
-#include "libnr/nr-forward.h"
-#include "sp-object-group.h"
-#include "uri-references.h"
-#include "xml/node.h"
-
struct SPMask : public SPObjectGroup {
unsigned int maskUnits_set : 1;
unsigned int maskUnits : 1;
@@ -93,7 +93,7 @@ protected:
Inkscape::DrawingItem *sp_mask_show (SPMask *mask, Inkscape::Drawing &drawing, unsigned int key);
void sp_mask_hide (SPMask *mask, unsigned int key);
-void sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox);
+void sp_mask_set_bbox (SPMask *mask, unsigned int key, Geom::OptRect const &bbox);
const gchar *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform);
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 71ee8298b..e94a02265 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -807,10 +807,7 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
}
// cancel any history of zooms up to this point
- if (desktop->zooms_past) {
- g_list_free(desktop->zooms_past);
- desktop->zooms_past = NULL;
- }
+ desktop->zooms_past.clear();
}
bool SPNamedView::getSnapGlobal() const
diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp
index 5187ff027..8617c096a 100644
--- a/src/sp-offset.cpp
+++ b/src/sp-offset.cpp
@@ -514,7 +514,7 @@ sp_offset_set_shape(SPShape *shape)
theRes->ConvertToForme (orig, 1, originaux);
SPItem *item = shape;
- Geom::OptRect bbox = item->getBboxDesktop ();
+ Geom::OptRect bbox = item->desktopVisualBounds();
if ( bbox ) {
gdouble size = L2(bbox->dimensions());
gdouble const exp = item->transform.descrim();
diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp
index 2ed556b23..ceb36740f 100644
--- a/src/sp-paint-server.cpp
+++ b/src/sp-paint-server.cpp
@@ -22,7 +22,7 @@
static void sp_paint_server_class_init(SPPaintServerClass *psc);
-static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity);
+static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity);
static SPObjectClass *parent_class;
@@ -70,14 +70,11 @@ void SPPaintServer::init(SPPaintServer * /*ps*/)
cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps,
cairo_t *ct,
- NRRect const *bbox,
+ Geom::OptRect const &bbox,
double opacity)
{
- // NOTE: the ct argument is used for when rendering patterns
- // to create a group, instead of explicitly creating a temporary surface
g_return_val_if_fail(ps != NULL, NULL);
g_return_val_if_fail(SP_IS_PAINT_SERVER(ps), NULL);
- g_return_val_if_fail(bbox != NULL, NULL);
cairo_pattern_t *cp = NULL;
SPPaintServerClass *psc = (SPPaintServerClass *) G_OBJECT_GET_CLASS(ps);
@@ -91,7 +88,7 @@ cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps,
static cairo_pattern_t *
sp_paint_server_create_dummy_pattern(SPPaintServer */*ps*/,
cairo_t */* ct */,
- NRRect const */*bbox*/,
+ Geom::OptRect const &/*bbox*/,
double /* opacity */)
{
cairo_pattern_t *cp = cairo_pattern_create_rgb(1.0, 0.0, 1.0);
diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h
index 283a97210..a266ee5a5 100644
--- a/src/sp-paint-server.h
+++ b/src/sp-paint-server.h
@@ -16,11 +16,10 @@
*/
#include <cairo.h>
+#include <2geom/rect.h>
#include "sp-object.h"
#include "uri-references.h"
-struct NRRect;
-
#define SP_TYPE_PAINT_SERVER (SPPaintServer::get_type())
#define SP_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_PAINT_SERVER, SPPaintServer))
#define SP_PAINT_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_PAINT_SERVER, SPPaintServerClass))
@@ -44,10 +43,10 @@ private:
struct SPPaintServerClass {
SPObjectClass sp_object_class;
/** Get SPPaint instance. */
- cairo_pattern_t *(*pattern_new)(SPPaintServer *ps, cairo_t *ct, const NRRect *bbox, double opacity);
+ cairo_pattern_t *(*pattern_new)(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity);
};
-cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity);
+cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity);
#endif // SEEN_SP_PAINT_SERVER_H
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index 9aefdf6ff..03afc1bf3 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -53,7 +53,7 @@ static void sp_pattern_modified (SPObject *object, unsigned int flags);
static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat);
static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern);
-static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity);
+static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity);
static SPPaintServerClass * pattern_parent_class;
@@ -245,11 +245,8 @@ sp_pattern_set (SPObject *object, unsigned int key, const gchar *value)
height = g_ascii_strtod (eptr, &eptr);
while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++;
if ((width > 0) && (height > 0)) {
- pat->viewBox.x0 = x;
- pat->viewBox.y0 = y;
- pat->viewBox.x1 = x + width;
- pat->viewBox.y1 = y + height;
- pat->viewBox_set = TRUE;
+ pat->viewBox = Geom::Rect::from_xywh(x, y, width, height);
+ pat->viewBox_set = TRUE;
} else {
pat->viewBox_set = FALSE;
}
@@ -581,13 +578,16 @@ gdouble pattern_height (SPPattern *pat)
return 0;
}
-NRRect *pattern_viewBox (SPPattern *pat)
+Geom::OptRect pattern_viewBox (SPPattern *pat)
{
- for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
- if (pat_i->viewBox_set)
- return &(pat_i->viewBox);
- }
- return &(pat->viewBox);
+ Geom::OptRect viewbox;
+ for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
+ if (pat_i->viewBox_set) {
+ viewbox = pat_i->viewBox;
+ break;
+ }
+ }
+ return viewbox;
}
bool pattern_hasItemChildren (SPPattern *pat)
@@ -604,7 +604,7 @@ bool pattern_hasItemChildren (SPPattern *pat)
static cairo_pattern_t *
sp_pattern_create_pattern(SPPaintServer *ps,
cairo_t *base_ct,
- NRRect const *bbox,
+ Geom::OptRect const &bbox,
double opacity)
{
SPPattern *pat = SP_PATTERN (ps);
@@ -647,17 +647,18 @@ sp_pattern_create_pattern(SPPaintServer *ps,
}
if (pat->viewBox_set) {
- gdouble tmp_x = pattern_width (pat) / (pattern_viewBox(pat)->x1 - pattern_viewBox(pat)->x0);
- gdouble tmp_y = pattern_height (pat) / (pattern_viewBox(pat)->y1 - pattern_viewBox(pat)->y0);
+ Geom::Rect vb = *pattern_viewBox(pat);
+ gdouble tmp_x = pattern_width (pat) / vb.width();
+ gdouble tmp_y = pattern_height (pat) / vb.height();
// FIXME: preserveAspectRatio must be taken into account here too!
- vb2ps = Geom::Affine(tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - pattern_viewBox(pat)->x0 * tmp_x, pattern_y(pat) - pattern_viewBox(pat)->y0 * tmp_y);
+ vb2ps = Geom::Affine(tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - vb.left() * tmp_x, pattern_y(pat) - vb.top() * tmp_y);
}
ps2user = pattern_patternTransform(pat);
if (!pat->viewBox_set && pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
/* BBox to user coordinate system */
- Geom::Affine bbox2user (bbox->x1 - bbox->x0, 0.0, 0.0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0);
+ Geom::Affine bbox2user (bbox->width(), 0.0, 0.0, bbox->height(), bbox->left(), bbox->top());
ps2user *= bbox2user;
}
ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user;
@@ -667,7 +668,7 @@ sp_pattern_create_pattern(SPPaintServer *ps,
if (pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
// interpret x, y, width, height in relation to bbox
- Geom::Affine bbox2user(bbox->x1 - bbox->x0, 0,0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0);
+ Geom::Affine bbox2user(bbox->width(), 0.0, 0.0, bbox->height(), bbox->left(), bbox->top());
pattern_tile = pattern_tile * bbox2user;
}
diff --git a/src/sp-pattern.h b/src/sp-pattern.h
index 1f545bfc4..acfa3e76e 100644
--- a/src/sp-pattern.h
+++ b/src/sp-pattern.h
@@ -27,7 +27,6 @@ GType sp_pattern_get_type (void);
class SPPatternClass;
-#include <libnr/nr-rect.h>
#include "svg/svg-length.h"
#include "sp-paint-server.h"
#include "uri-references.h"
@@ -72,7 +71,7 @@ struct SPPattern : public SPPaintServer {
SVGLength width;
SVGLength height;
/* VieBox */
- NRRect viewBox;
+ Geom::Rect viewBox;
guint viewBox_set : 1;
sigc::connection modified_connection;
@@ -98,7 +97,7 @@ gdouble pattern_x (SPPattern *pat);
gdouble pattern_y (SPPattern *pat);
gdouble pattern_width (SPPattern *pat);
gdouble pattern_height (SPPattern *pat);
-NRRect *pattern_viewBox (SPPattern *pat);
+Geom::OptRect pattern_viewBox (SPPattern *pat);
#endif // SEEN_SP_PATTERN_H
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index 729e2a34c..22a403345 100644
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
@@ -173,8 +173,8 @@ sp_rect_update(SPObject *object, SPCtx *ctx, guint flags)
SPRect *rect = (SPRect *) object;
SPStyle *style = object->style;
SPItemCtx const *ictx = (SPItemCtx const *) ctx;
- double const w = (ictx->vp.x1 - ictx->vp.x0);
- double const h = (ictx->vp.y1 - ictx->vp.y0);
+ double const w = ictx->viewport.width();
+ double const h = ictx->viewport.height();
double const em = style->font_size.computed;
double const ex = 0.5 * em; // fixme: get x height from pango or libnrtype.
rect->x.update(em, ex, w);
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index a6df580d3..788d1958a 100644
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -123,7 +123,6 @@ sp_root_init(SPRoot *root)
root->width.unset(SVGLength::PERCENT, 1.0, 1.0);
root->height.unset(SVGLength::PERCENT, 1.0, 1.0);
- /* root->viewbox.set_identity(); */
root->viewBox_set = FALSE;
root->c2p.setIdentity();
@@ -253,10 +252,7 @@ sp_root_set(SPObject *object, unsigned int key, gchar const *value)
while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++;
if ((width > 0) && (height > 0)) {
/* Set viewbox */
- root->viewBox.x0 = x;
- root->viewBox.y0 = y;
- root->viewBox.x1 = x + width;
- root->viewBox.y1 = y + height;
+ root->viewBox = Geom::Rect::from_xywh(x, y, width, height);
root->viewBox_set = TRUE;
} else {
root->viewBox_set = FALSE;
@@ -404,16 +400,16 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags)
/* fixme: We should calculate only if parent viewport has changed (Lauris) */
/* If position is specified as percentage, calculate actual values */
if (root->x.unit == SVGLength::PERCENT) {
- root->x.computed = root->x.value * (ictx->vp.x1 - ictx->vp.x0);
+ root->x.computed = root->x.value * ictx->viewport.width();
}
if (root->y.unit == SVGLength::PERCENT) {
- root->y.computed = root->y.value * (ictx->vp.y1 - ictx->vp.y0);
+ root->y.computed = root->y.value * ictx->viewport.height();
}
if (root->width.unit == SVGLength::PERCENT) {
- root->width.computed = root->width.value * (ictx->vp.x1 - ictx->vp.x0);
+ root->width.computed = root->width.value * ictx->viewport.width();
}
if (root->height.unit == SVGLength::PERCENT) {
- root->height.computed = root->height.value * (ictx->vp.y1 - ictx->vp.y0);
+ root->height.computed = root->height.value * ictx->viewport.height();
}
/* Create copy of item context */
@@ -445,11 +441,11 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags)
} else {
double scalex, scaley, scale;
/* Things are getting interesting */
- scalex = root->width.computed / (root->viewBox.x1 - root->viewBox.x0);
- scaley = root->height.computed / (root->viewBox.y1 - root->viewBox.y0);
+ scalex = root->width.computed / root->viewBox.width();
+ scaley = root->height.computed / root->viewBox.height();
scale = (root->aspect_clip == SP_ASPECT_MEET) ? MIN(scalex, scaley) : MAX(scalex, scaley);
- width = (root->viewBox.x1 - root->viewBox.x0) * scale;
- height = (root->viewBox.y1 - root->viewBox.y0) * scale;
+ width = root->viewBox.width() * scale;
+ height = root->viewBox.height() * scale;
/* Now place viewbox to requested position */
/* todo: Use an array lookup to find the 0.0/0.5/1.0 coefficients,
as is done for dialogs/align.cpp. */
@@ -498,38 +494,27 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags)
}
/* Compose additional transformation from scale and position */
- Geom::Point const viewBox_min(root->viewBox.x0,
- root->viewBox.y0);
- Geom::Point const viewBox_max(root->viewBox.x1,
- root->viewBox.y1);
- Geom::Scale const viewBox_length( viewBox_max - viewBox_min );
+ Geom::Scale const viewBox_length( root->viewBox.dimensions() );
Geom::Scale const new_length(width, height);
/* Append viewbox transformation */
/* TODO: The below looks suspicious to me (pjrm): I wonder whether the RHS
expression should have c2p at the beginning rather than at the end. Test it. */
- root->c2p = Geom::Translate(-viewBox_min) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * root->c2p;
+ root->c2p = Geom::Translate(-root->viewBox.min()) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * root->c2p;
}
rctx.i2doc = root->c2p * rctx.i2doc;
/* Initialize child viewport */
if (root->viewBox_set) {
- rctx.vp.x0 = root->viewBox.x0;
- rctx.vp.y0 = root->viewBox.y0;
- rctx.vp.x1 = root->viewBox.x1;
- rctx.vp.y1 = root->viewBox.y1;
+ rctx.viewport = root->viewBox;
} else {
/* fixme: I wonder whether this logic is correct (Lauris) */
+ Geom::Point minp(0,0);
if (object->parent) {
- rctx.vp.x0 = root->x.computed;
- rctx.vp.y0 = root->y.computed;
- } else {
- rctx.vp.x0 = 0.0;
- rctx.vp.y0 = 0.0;
+ minp = Geom::Point(root->x.computed, root->y.computed);
}
- rctx.vp.x1 = root->width.computed;
- rctx.vp.y1 = root->height.computed;
+ rctx.viewport = Geom::Rect::from_xywh(minp[Geom::X], minp[Geom::Y], root->width.computed, root->height.computed);
}
rctx.i2vp = Geom::identity();
@@ -597,7 +582,8 @@ sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:
if (root->viewBox_set) {
Inkscape::SVGOStringStream os;
- os << root->viewBox.x0 << " " << root->viewBox.y0 << " " << root->viewBox.x1 - root->viewBox.x0 << " " << root->viewBox.y1 - root->viewBox.y0;
+ os << root->viewBox.left() << " " << root->viewBox.top() << " "
+ << root->viewBox.width() << " " << root->viewBox.height();
repr->setAttribute("viewBox", os.str().c_str());
}
diff --git a/src/sp-root.h b/src/sp-root.h
index 86b92b2b3..e2bad917b 100644
--- a/src/sp-root.h
+++ b/src/sp-root.h
@@ -1,6 +1,3 @@
-#ifndef SP_ROOT_H_SEEN
-#define SP_ROOT_H_SEEN
-
/** \file
* SPRoot: SVG \<svg\> implementation.
*/
@@ -14,17 +11,20 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#define SP_TYPE_ROOT (sp_root_get_type())
-#define SP_ROOT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ROOT, SPRoot))
-#define SP_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_ROOT, SPRootClass))
-#define SP_IS_ROOT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ROOT))
-#define SP_IS_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ROOT))
+#ifndef SP_ROOT_H_SEEN
+#define SP_ROOT_H_SEEN
#include "version.h"
#include "svg/svg-length.h"
#include "enums.h"
#include "sp-item-group.h"
+#define SP_TYPE_ROOT (sp_root_get_type())
+#define SP_ROOT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ROOT, SPRoot))
+#define SP_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_ROOT, SPRootClass))
+#define SP_IS_ROOT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ROOT))
+#define SP_IS_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ROOT))
+
class SPDefs;
/** \<svg\> element */
@@ -41,7 +41,7 @@ struct SPRoot : public SPGroup {
/* viewBox; */
unsigned int viewBox_set : 1;
- NRRect viewBox;
+ Geom::Rect viewBox;
/* preserveAspectRatio */
unsigned int aspect_set : 1;
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 4fd1deb69..8bfa99392 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -502,216 +502,163 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags)
* Calculates the bounding box for item, storing it into bbox.
* This also includes the bounding boxes of any markers included in the shape.
*/
-void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags)
+Geom::OptRect SPShape::sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType bboxtype)
{
SPShape const *shape = SP_SHAPE (item);
- SPItem::BBoxType bboxtype = (SPItem::BBoxType) flags;
-
- if (shape->curve) {
- Geom::OptRect geombbox = bounds_exact_transformed(shape->curve->get_pathvector(), transform);
- if (geombbox) {
- NRRect cbbox;
- cbbox.x0 = (*geombbox)[0][0];
- cbbox.y0 = (*geombbox)[1][0];
- cbbox.x1 = (*geombbox)[0][1];
- cbbox.y1 = (*geombbox)[1][1];
-
- switch (bboxtype) {
- case SPItem::GEOMETRIC_BBOX: {
- // do nothing
- break;
- }
- case SPItem::RENDERING_BBOX: {
- // convert the stroke to a path and calculate that path's geometric bbox
- SPStyle* style = item->style;
- if (!style->stroke.isNone()) {
- Geom::PathVector *pathv = item_outline(item);
- if (pathv) {
- Geom::OptRect geomstrokebbox = bounds_exact_transformed(*pathv, transform);
- if (geomstrokebbox) {
- NRRect strokebbox;
- strokebbox.x0 = (*geomstrokebbox)[0][0];
- strokebbox.y0 = (*geomstrokebbox)[1][0];
- strokebbox.x1 = (*geomstrokebbox)[0][1];
- strokebbox.y1 = (*geomstrokebbox)[1][1];
- nr_rect_d_union (&cbbox, &cbbox, &strokebbox);
- }
- delete pathv;
+ Geom::OptRect bbox;
+
+ if (!shape->curve) return bbox;
+ bbox = bounds_exact_transformed(shape->curve->get_pathvector(), transform);
+ if (!bbox) return bbox;
+
+ if (bboxtype == SPItem::VISUAL_BBOX) {
+ // convert the stroke to a path and calculate that path's geometric bbox
+ SPStyle* style = item->style;
+ if (!style->stroke.isNone()) {
+ Geom::PathVector *pathv = item_outline(item);
+ if (pathv) {
+ bbox |= bounds_exact_transformed(*pathv, transform);
+ delete pathv;
+ }
+ }
+ // Union with bboxes of the markers, if any
+ if ( shape->hasMarkers() && !shape->curve->get_pathvector().empty() ) {
+ /** \todo make code prettier! */
+ Geom::PathVector const & pathv = shape->curve->get_pathvector();
+ // START marker
+ for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START
+ if ( shape->marker[i] ) {
+ SPMarker* marker = SP_MARKER (shape->marker[i]);
+ SPItem* marker_item = sp_item_first_item_child( marker );
+
+ if (marker_item) {
+ Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front()));
+ if (!marker->orient_auto) {
+ Geom::Point transl = tr.translation();
+ tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
+ }
+ if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
+
+ // total marker transform
+ tr = marker_item->transform * marker->c2p * tr * transform;
+
+ // get bbox of the marker with that transform
+ bbox |= marker_item->visualBounds(tr);
}
- break;
}
- default:
- case SPItem::APPROXIMATE_BBOX: {
- SPStyle* style = item->style;
- if (!style->stroke.isNone()) {
- double const scale = transform.descrim();
- if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
- double const width = MAX(0.125, style->stroke_width.computed * scale);
- if ( fabs(cbbox.x1-cbbox.x0) > -0.00001 && fabs(cbbox.y1-cbbox.y0) > -0.00001 ) {
- cbbox.x0-=0.5*width;
- cbbox.x1+=0.5*width;
- cbbox.y0-=0.5*width;
- cbbox.y1+=0.5*width;
- }
+ }
+ // MID marker
+ for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID
+ SPMarker* marker = SP_MARKER (shape->marker[i]);
+ if ( !shape->marker[i] ) continue;
+ SPItem* marker_item = sp_item_first_item_child( marker );
+ if ( !marker_item ) continue;
+
+ for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
+ // START position
+ if ( path_it != pathv.begin()
+ && ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there
+ {
+ Geom::Affine tr(sp_shape_marker_get_transform_at_start(path_it->front()));
+ if (!marker->orient_auto) {
+ Geom::Point transl = tr.translation();
+ tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
}
+ if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
+ }
+ tr = marker_item->transform * marker->c2p * tr * transform;
+ bbox |= marker_item->visualBounds(tr);
}
+ // MID position
+ if ( path_it->size_default() > 1) {
+ Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve
+ Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve
+ while (curve_it2 != path_it->end_default())
+ {
+ /* Put marker between curve_it1 and curve_it2.
+ * Loop to end_default (so including closing segment), because when a path is closed,
+ * there should be a midpoint marker between last segment and closing straight line segment */
- // Union with bboxes of the markers, if any
- if ( shape->hasMarkers() && !shape->curve->get_pathvector().empty() ) {
- /** \todo make code prettier! */
- Geom::PathVector const & pathv = shape->curve->get_pathvector();
- // START marker
- for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START
- if ( shape->marker[i] ) {
- SPMarker* marker = SP_MARKER (shape->marker[i]);
- SPItem* marker_item = sp_item_first_item_child( marker );
-
- if (marker_item) {
- Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front()));
- if (!marker->orient_auto) {
- Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
- }
- if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
- }
-
- // total marker transform
- tr = marker_item->transform * marker->c2p * tr * transform;
-
- // get bbox of the marker with that transform
- NRRect marker_bbox;
- marker_item->invoke_bbox ( &marker_bbox, tr, true);
- // union it with the shape bbox
- nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
- }
- }
- }
- // MID marker
- for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID
SPMarker* marker = SP_MARKER (shape->marker[i]);
- if ( !shape->marker[i] ) continue;
SPItem* marker_item = sp_item_first_item_child( marker );
- if ( !marker_item ) continue;
-
- for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
- // START position
- if ( path_it != pathv.begin()
- && ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there
- {
- Geom::Affine tr(sp_shape_marker_get_transform_at_start(path_it->front()));
- if (!marker->orient_auto) {
- Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
- }
- if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
- }
- tr = marker_item->transform * marker->c2p * tr * transform;
- NRRect marker_bbox;
- marker_item->invoke_bbox ( &marker_bbox, tr, true);
- nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
- }
- // MID position
- if ( path_it->size_default() > 1) {
- Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve
- Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve
- while (curve_it2 != path_it->end_default())
- {
- /* Put marker between curve_it1 and curve_it2.
- * Loop to end_default (so including closing segment), because when a path is closed,
- * there should be a midpoint marker between last segment and closing straight line segment */
-
- SPMarker* marker = SP_MARKER (shape->marker[i]);
- SPItem* marker_item = sp_item_first_item_child( marker );
-
- if (marker_item) {
- Geom::Affine tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2));
- if (!marker->orient_auto) {
- Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
- }
- if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
- }
- tr = marker_item->transform * marker->c2p * tr * transform;
- NRRect marker_bbox;
- marker_item->invoke_bbox ( &marker_bbox, tr, true);
- nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
- }
-
- ++curve_it1;
- ++curve_it2;
- }
+
+ if (marker_item) {
+ Geom::Affine tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2));
+ if (!marker->orient_auto) {
+ Geom::Point transl = tr.translation();
+ tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
}
- // END position
- if ( path_it != (pathv.end()-1) && !path_it->empty()) {
- Geom::Curve const &lastcurve = path_it->back_default();
- Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve);
- if (!marker->orient_auto) {
- Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
- }
- if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
- }
- tr = marker_item->transform * marker->c2p * tr * transform;
- NRRect marker_bbox;
- marker_item->invoke_bbox ( &marker_bbox, tr, true);
- nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
+ if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
+ tr = marker_item->transform * marker->c2p * tr * transform;
+ bbox |= marker_item->visualBounds(tr);
}
+
+ ++curve_it1;
+ ++curve_it2;
}
- // END marker
- for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END
- if ( shape->marker[i] ) {
- SPMarker* marker = SP_MARKER (shape->marker[i]);
- SPItem* marker_item = sp_item_first_item_child( marker );
-
- if (marker_item) {
- /* Get reference to last curve in the path.
- * For moveto-only path, this returns the "closing line segment". */
- Geom::Path const &path_last = pathv.back();
- unsigned int index = path_last.size_default();
- if (index > 0) {
- index--;
- }
- Geom::Curve const &lastcurve = path_last[index];
-
- Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve);
- if (!marker->orient_auto) {
- Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
- }
- if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = Geom::Scale(style->stroke_width.computed) * tr;
- }
-
- // total marker transform
- tr = marker_item->transform * marker->c2p * tr * transform;
-
- // get bbox of the marker with that transform
- NRRect marker_bbox;
- marker_item->invoke_bbox ( &marker_bbox, tr, true);
- // union it with the shape bbox
- nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
- }
- }
+ }
+ // END position
+ if ( path_it != (pathv.end()-1) && !path_it->empty()) {
+ Geom::Curve const &lastcurve = path_it->back_default();
+ Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve);
+ if (!marker->orient_auto) {
+ Geom::Point transl = tr.translation();
+ tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
+ }
+ if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
+ tr = marker_item->transform * marker->c2p * tr * transform;
+ bbox |= marker_item->visualBounds();
}
- break;
- } // end case approximate bbox type
- } // end switch bboxtype
+ }
+ }
+ // END marker
+ for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END
+ if ( shape->marker[i] ) {
+ SPMarker* marker = SP_MARKER (shape->marker[i]);
+ SPItem* marker_item = sp_item_first_item_child( marker );
+
+ if (marker_item) {
+ /* Get reference to last curve in the path.
+ * For moveto-only path, this returns the "closing line segment". */
+ Geom::Path const &path_last = pathv.back();
+ unsigned int index = path_last.size_default();
+ if (index > 0) {
+ index--;
+ }
+ Geom::Curve const &lastcurve = path_last[index];
+
+ Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve);
+ if (!marker->orient_auto) {
+ Geom::Point transl = tr.translation();
+ tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
+ }
+ if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
+ }
+
+ // total marker transform
+ tr = marker_item->transform * marker->c2p * tr * transform;
- // copy our bbox to the variable we're given
- *bbox = cbbox;
+ // get bbox of the marker with that transform
+ bbox |= marker_item->visualBounds(tr);
+ }
+ }
+ }
}
}
+ return bbox;
}
static void
-sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* style, SPPrintContext *ctx) {
+sp_shape_print_invoke_marker_printing(SPObject *obj, Geom::Affine tr, SPStyle const *style, SPPrintContext *ctx)
+{
SPMarker *marker = SP_MARKER(obj);
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
tr = Geom::Scale(style->stroke_width.computed) * tr;
@@ -736,7 +683,7 @@ sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* s
void
sp_shape_print (SPItem *item, SPPrintContext *ctx)
{
- NRRect pbox, dbox, bbox;
+ Geom::OptRect pbox, dbox, bbox;
SPShape *shape = SP_SHAPE(item);
@@ -755,22 +702,19 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
}
/* fixme: Think (Lauris) */
- item->invoke_bbox( &pbox, Geom::identity(), TRUE);
- dbox.x0 = 0.0;
- dbox.y0 = 0.0;
- dbox.x1 = item->document->getWidth();
- dbox.y1 = item->document->getHeight();
- item->getBboxDesktop (&bbox);
+ pbox = item->geometricBounds();
+ bbox = item->desktopVisualBounds();
+ dbox = Geom::Rect::from_xywh(Geom::Point(0,0), item->document->getDimensions());
Geom::Affine const i2dt(item->i2dt_affine());
SPStyle* style = item->style;
if (!style->fill.isNone()) {
- sp_print_fill (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox);
+ sp_print_fill (ctx, pathv, i2dt, style, pbox, dbox, bbox);
}
if (!style->stroke.isNone()) {
- sp_print_stroke (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox);
+ sp_print_stroke (ctx, pathv, i2dt, style, pbox, dbox, bbox);
}
/** \todo make code prettier */
@@ -1184,7 +1128,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::Snap
Geom::Affine const i2dt (item->i2dt_affine ());
if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) {
- Geom::OptRect bbox = item->getBounds(i2dt);
+ Geom::OptRect bbox = item->desktopVisualBounds();
if (bbox) {
p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT));
}
diff --git a/src/sp-shape.h b/src/sp-shape.h
index 355d8e7cc..06bd704ad 100644
--- a/src/sp-shape.h
+++ b/src/sp-shape.h
@@ -66,7 +66,7 @@ private:
static void sp_shape_modified (SPObject *object, unsigned int flags);
static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
- static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+ static Geom::OptRect sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static Inkscape::DrawingItem *sp_shape_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
static void sp_shape_hide (SPItem *item, unsigned int key);
static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp
index bee28f8e3..87cd210e4 100644
--- a/src/sp-symbol.cpp
+++ b/src/sp-symbol.cpp
@@ -39,7 +39,7 @@ static Inkscape::XML::Node *sp_symbol_write (SPObject *object, Inkscape::XML::Do
static Inkscape::DrawingItem *sp_symbol_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
static void sp_symbol_hide (SPItem *item, unsigned int key);
-static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static void sp_symbol_print (SPItem *item, SPPrintContext *ctx);
static SPGroupClass *parent_class;
@@ -131,10 +131,7 @@ static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value
while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++;
if ((width > 0) && (height > 0)) {
/* Set viewbox */
- symbol->viewBox.x0 = x;
- symbol->viewBox.y0 = y;
- symbol->viewBox.x1 = x + width;
- symbol->viewBox.y1 = y + height;
+ symbol->viewBox = Geom::Rect::from_xywh(x, y, width, height);
symbol->viewBox_set = TRUE;
} else {
symbol->viewBox_set = FALSE;
@@ -234,7 +231,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags)
/* Calculate child to parent transformation */
/* Apply parent <use> translation (set up as vewport) */
- symbol->c2p = Geom::Affine(Geom::Translate(rctx.vp.x0, rctx.vp.y0));
+ symbol->c2p = Geom::Translate(rctx.viewport.min());
if (symbol->viewBox_set) {
double x, y, width, height;
@@ -242,16 +239,16 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags)
if (symbol->aspect_align == SP_ASPECT_NONE) {
x = 0.0;
y = 0.0;
- width = rctx.vp.x1 - rctx.vp.x0;
- height = rctx.vp.y1 - rctx.vp.y0;
+ width = rctx.viewport.width();
+ height = rctx.viewport.height();
} else {
double scalex, scaley, scale;
/* Things are getting interesting */
- scalex = (rctx.vp.x1 - rctx.vp.x0) / (symbol->viewBox.x1 - symbol->viewBox.x0);
- scaley = (rctx.vp.y1 - rctx.vp.y0) / (symbol->viewBox.y1 - symbol->viewBox.y0);
+ scalex = rctx.viewport.width() / symbol->viewBox.width();
+ scaley = rctx.viewport.height() / symbol->viewBox.height();
scale = (symbol->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley);
- width = (symbol->viewBox.x1 - symbol->viewBox.x0) * scale;
- height = (symbol->viewBox.y1 - symbol->viewBox.y0) * scale;
+ width = symbol->viewBox.width() * scale;
+ height = symbol->viewBox.height() * scale;
/* Now place viewbox to requested position */
switch (symbol->aspect_align) {
case SP_ASPECT_XMIN_YMIN:
@@ -259,36 +256,36 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags)
y = 0.0;
break;
case SP_ASPECT_XMID_YMIN:
- x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width);
+ x = 0.5 * (rctx.viewport.width() - width);
y = 0.0;
break;
case SP_ASPECT_XMAX_YMIN:
- x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width);
+ x = 1.0 * (rctx.viewport.width() - width);
y = 0.0;
break;
case SP_ASPECT_XMIN_YMID:
x = 0.0;
- y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ y = 0.5 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMID_YMID:
- x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width);
- y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ x = 0.5 * (rctx.viewport.width() - width);
+ y = 0.5 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMAX_YMID:
- x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width);
- y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ x = 1.0 * (rctx.viewport.width() - width);
+ y = 0.5 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMIN_YMAX:
x = 0.0;
- y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ y = 1.0 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMID_YMAX:
- x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width);
- y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ x = 0.5 * (rctx.viewport.width() - width);
+ y = 1.0 * (rctx.viewport.height() - height);
break;
case SP_ASPECT_XMAX_YMAX:
- x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width);
- y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height);
+ x = 1.0 * (rctx.viewport.width() - width);
+ y = 1.0 * (rctx.viewport.height() - height);
break;
default:
x = 0.0;
@@ -298,12 +295,12 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags)
}
/* Compose additional transformation from scale and position */
Geom::Affine q;
- q[0] = width / (symbol->viewBox.x1 - symbol->viewBox.x0);
+ q[0] = width / symbol->viewBox.width();
q[1] = 0.0;
q[2] = 0.0;
- q[3] = height / (symbol->viewBox.y1 - symbol->viewBox.y0);
- q[4] = -symbol->viewBox.x0 * q[0] + x;
- q[5] = -symbol->viewBox.y0 * q[3] + y;
+ q[3] = height / symbol->viewBox.height();
+ q[4] = -symbol->viewBox.left() * q[0] + x;
+ q[5] = -symbol->viewBox.top() * q[3] + y;
/* Append viewbox transformation */
symbol->c2p = q * symbol->c2p;
}
@@ -313,10 +310,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags)
/* If viewBox is set initialize child viewport */
/* Otherwise <use> has set it up already */
if (symbol->viewBox_set) {
- rctx.vp.x0 = symbol->viewBox.x0;
- rctx.vp.y0 = symbol->viewBox.y0;
- rctx.vp.x1 = symbol->viewBox.x1;
- rctx.vp.y1 = symbol->viewBox.y1;
+ rctx.viewport = symbol->viewBox;
rctx.i2vp = Geom::identity();
}
@@ -399,18 +393,20 @@ static void sp_symbol_hide(SPItem *item, unsigned int key)
}
}
-static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags)
+static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type)
{
SPSymbol const *symbol = SP_SYMBOL(item);
+ Geom::OptRect bbox;
if (symbol->cloned) {
// Cloned <symbol> is actually renderable
if (((SPItemClass *) (parent_class))->bbox) {
Geom::Affine const a( symbol->c2p * transform );
- ((SPItemClass *) (parent_class))->bbox(item, bbox, a, flags);
+ bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type);
}
}
+ return bbox;
}
static void sp_symbol_print(SPItem *item, SPPrintContext *ctx)
@@ -419,7 +415,7 @@ static void sp_symbol_print(SPItem *item, SPPrintContext *ctx)
if (symbol->cloned) {
// Cloned <symbol> is actually renderable
- sp_print_bind(ctx, &symbol->c2p, 1.0);
+ sp_print_bind(ctx, symbol->c2p, 1.0);
if (((SPItemClass *) (parent_class))->print) {
((SPItemClass *) (parent_class))->print (item, ctx);
diff --git a/src/sp-symbol.h b/src/sp-symbol.h
index 120591459..59f343285 100644
--- a/src/sp-symbol.h
+++ b/src/sp-symbol.h
@@ -25,7 +25,6 @@ class SPSymbol;
class SPSymbolClass;
#include <2geom/affine.h>
-#include <libnr/nr-rect.h>
#include "svg/svg-length.h"
#include "enums.h"
#include "sp-item-group.h"
@@ -33,7 +32,7 @@ class SPSymbolClass;
struct SPSymbol : public SPGroup {
/* viewBox; */
unsigned int viewBox_set : 1;
- NRRect viewBox;
+ Geom::Rect viewBox;
/* preserveAspectRatio */
unsigned int aspect_set : 1;
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index 9bb674843..fc248824d 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -71,7 +71,7 @@ static void sp_text_update (SPObject *object, SPCtx *ctx, guint flags);
static void sp_text_modified (SPObject *object, guint flags);
static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-static void sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static Inkscape::DrawingItem *sp_text_show (SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags);
static void sp_text_hide (SPItem *item, unsigned key);
static char *sp_text_description (SPItem *item);
@@ -248,14 +248,13 @@ static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags)
/* fixme: So check modification flag everywhere immediate state is used */
text->rebuildLayout();
- NRRect paintbox;
- text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
+ Geom::OptRect paintbox = text->geometricBounds();
for (SPItemView* v = text->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
text->_clearFlow(g);
g->setStyle(object->style);
// pass the bbox of the text object as paintbox (used for paintserver fills)
- text->layout.show(g, &paintbox);
+ text->layout.show(g, paintbox);
}
}
}
@@ -277,13 +276,12 @@ static void sp_text_modified(SPObject *object, guint flags)
// and create new ones. This is probably quite wasteful.
if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
SPText *text = SP_TEXT (object);
- NRRect paintbox;
- text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
+ Geom::OptRect paintbox = text->geometricBounds();
for (SPItemView* v = text->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
text->_clearFlow(g);
g->setStyle(object->style);
- text->layout.show(g, &paintbox);
+ text->layout.show(g, paintbox);
}
}
@@ -363,25 +361,17 @@ static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Docum
return repr;
}
-static void
-sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/)
+static Geom::OptRect
+sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type)
{
- SP_TEXT(item)->layout.getBoundingBox(bbox, transform);
-
- // Add stroke width
- SPStyle* style = item->style;
- if (!style->stroke.isNone()) {
- double const scale = transform.descrim();
- if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
- double const width = MAX(0.125, style->stroke_width.computed * scale);
- if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
- bbox->x0-=0.5*width;
- bbox->x1+=0.5*width;
- bbox->y0-=0.5*width;
- bbox->y1+=0.5*width;
- }
- }
+ Geom::OptRect bbox = SP_TEXT(item)->layout.bounds(transform);
+
+ // FIXME this code is incorrect
+ if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) {
+ double scale = transform.descrim();
+ bbox->expandBy(0.5 * item->style->stroke_width.computed * scale);
}
+ return bbox;
}
@@ -395,9 +385,7 @@ sp_text_show(SPItem *item, Inkscape::Drawing &drawing, unsigned /* key*/, unsign
flowed->setStyle(group->style);
// pass the bbox of the text object as paintbox (used for paintserver fills)
- NRRect paintbox;
- item->invoke_bbox( &paintbox, Geom::identity(), TRUE);
- group->layout.show(flowed, &paintbox);
+ group->layout.show(flowed, group->geometricBounds());
return flowed;
}
@@ -509,18 +497,15 @@ sp_text_set_transform (SPItem *item, Geom::Affine const &xform)
static void
sp_text_print (SPItem *item, SPPrintContext *ctx)
{
- NRRect pbox, dbox, bbox;
SPText *group = SP_TEXT (item);
+ Geom::OptRect pbox, bbox, dbox;
- item->invoke_bbox( &pbox, Geom::identity(), TRUE);
- item->getBboxDesktop (&bbox);
- dbox.x0 = 0.0;
- dbox.y0 = 0.0;
- dbox.x1 = item->document->getWidth();
- dbox.y1 = item->document->getHeight();
+ pbox = item->geometricBounds();
+ bbox = item->desktopVisualBounds();
+ dbox = Geom::Rect::from_xywh(Geom::Point(0,0), item->document->getDimensions());
Geom::Affine const ctm (item->i2dt_affine());
- group->layout.print(ctx,&pbox,&dbox,&bbox,ctm);
+ group->layout.print(ctx,pbox,dbox,bbox,ctm);
}
/*
diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp
index dcf46f6ac..ac20ce098 100644
--- a/src/sp-tref.cpp
+++ b/src/sp-tref.cpp
@@ -63,7 +63,7 @@ static void sp_tref_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_tref_modified(SPObject *object, guint flags);
static Inkscape::XML::Node *sp_tref_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-static void sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static gchar *sp_tref_description(SPItem *item);
static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref);
@@ -314,39 +314,33 @@ sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:
return repr;
}
-/**
+/*
* The code for this function is swiped from the tspan bbox code, since tref should work pretty much the same way
*/
-static void
-sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/)
+static Geom::OptRect
+sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type)
{
+ Geom::OptRect bbox;
// find out the ancestor text which holds our layout
SPObject const *parent_text = item;
while ( parent_text && !SP_IS_TEXT(parent_text) ) {
parent_text = parent_text->parent;
}
if (parent_text == NULL) {
- return;
+ return bbox;
}
// get the bbox of our portion of the layout
- SP_TEXT(parent_text)->layout.getBoundingBox(
- bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1);
+ bbox = SP_TEXT(parent_text)->layout.bounds(transform,
+ sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1);
// Add stroke width
- SPStyle* style = item->style;
- if (!style->stroke.isNone()) {
- double const scale = transform.descrim();
- if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
- double const width = MAX(0.125, style->stroke_width.computed * scale);
- if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
- bbox->x0-=0.5*width;
- bbox->x1+=0.5*width;
- bbox->y0-=0.5*width;
- bbox->y1+=0.5*width;
- }
- }
+ // FIXME this code is incorrect
+ if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) {
+ double scale = transform.descrim();
+ bbox->expandBy(0.5 * item->style->stroke_width.computed * scale);
}
+ return bbox;
}
diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index 199d82e1b..f4e79f7d5 100644
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
@@ -56,7 +56,7 @@ static void sp_tspan_release(SPObject *object);
static void sp_tspan_set(SPObject *object, unsigned key, gchar const *value);
static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_tspan_modified(SPObject *object, unsigned flags);
-static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static char *sp_tspan_description (SPItem *item);
@@ -203,34 +203,30 @@ static void sp_tspan_modified(SPObject *object, unsigned flags)
}
}
-static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/)
+static Geom::OptRect
+sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type)
{
+ Geom::OptRect bbox;
// find out the ancestor text which holds our layout
SPObject const *parent_text = item;
while (parent_text && !SP_IS_TEXT(parent_text)) {
parent_text = parent_text->parent;
}
if (parent_text == NULL) {
- return;
+ return bbox;
}
// get the bbox of our portion of the layout
- SP_TEXT(parent_text)->layout.getBoundingBox(bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1);
+ bbox = SP_TEXT(parent_text)->layout.bounds(transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1);
+ if (!bbox) return bbox;
// Add stroke width
- SPStyle* style = item->style;
- if (!style->stroke.isNone()) {
- double const scale = transform.descrim();
- if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
- double const width = MAX(0.125, style->stroke_width.computed * scale);
- if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
- bbox->x0-=0.5*width;
- bbox->x1+=0.5*width;
- bbox->y0-=0.5*width;
- bbox->y1+=0.5*width;
- }
- }
+ // FIXME this code is incorrect
+ if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) {
+ double scale = transform.descrim();
+ bbox->expandBy(0.5 * item->style->stroke_width.computed * scale);
}
+ return bbox;
}
static Inkscape::XML::Node *
@@ -592,8 +588,7 @@ sp_textpath_to_text(SPObject *tp)
{
SPObject *text = tp->parent;
- Geom::OptRect bbox;
- SP_ITEM(text)->invoke_bbox(bbox, SP_ITEM(text)->i2doc_affine(), TRUE);
+ Geom::OptRect bbox = SP_ITEM(text)->geometricBounds(SP_ITEM(text)->i2doc_affine());
if (!bbox) return;
Geom::Point xy = bbox->min();
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index 89df9130d..04cf1eb2c 100644
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
@@ -49,7 +49,7 @@ static Inkscape::XML::Node *sp_use_write(SPObject *object, Inkscape::XML::Docume
static void sp_use_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_use_modified(SPObject *object, guint flags);
-static void sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags);
+static Geom::OptRect sp_use_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type);
static void sp_use_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
static void sp_use_print(SPItem *item, SPPrintContext *ctx);
static gchar *sp_use_description(SPItem *item);
@@ -276,10 +276,11 @@ sp_use_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::
return repr;
}
-static void
-sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags)
+static Geom::OptRect
+sp_use_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type)
{
SPUse const *use = SP_USE(item);
+ Geom::OptRect bbox;
if (use->child && SP_IS_ITEM(use->child)) {
SPItem *child = SP_ITEM(use->child);
@@ -287,15 +288,9 @@ sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, uns
* Geom::Translate(use->x.computed,
use->y.computed)
* transform );
- Geom::OptRect optbbox;
- child->invoke_bbox_full( optbbox, ct, flags, FALSE);
- if (optbbox) {
- bbox->x0 = (*optbbox)[0][0];
- bbox->y0 = (*optbbox)[1][0];
- bbox->x1 = (*optbbox)[0][1];
- bbox->y1 = (*optbbox)[1][1];
- }
+ bbox = child->bounds(type, ct);
}
+ return bbox;
}
static void
@@ -599,21 +594,18 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags)
/* Set up child viewport */
if (use->x.unit == SVGLength::PERCENT) {
- use->x.computed = use->x.value * (ictx->vp.x1 - ictx->vp.x0);
+ use->x.computed = use->x.value * ictx->viewport.width();
}
if (use->y.unit == SVGLength::PERCENT) {
- use->y.computed = use->y.value * (ictx->vp.y1 - ictx->vp.y0);
+ use->y.computed = use->y.value * ictx->viewport.height();
}
if (use->width.unit == SVGLength::PERCENT) {
- use->width.computed = use->width.value * (ictx->vp.x1 - ictx->vp.x0);
+ use->width.computed = use->width.value * ictx->viewport.width();
}
if (use->height.unit == SVGLength::PERCENT) {
- use->height.computed = use->height.value * (ictx->vp.y1 - ictx->vp.y0);
+ use->height.computed = use->height.value * ictx->viewport.height();
}
- cctx.vp.x0 = 0.0;
- cctx.vp.y0 = 0.0;
- cctx.vp.x1 = use->width.computed;
- cctx.vp.y1 = use->height.computed;
+ cctx.viewport = Geom::Rect::from_xywh(0, 0, use->width.computed, use->height.computed);
cctx.i2vp = Geom::identity();
flags&=~SP_OBJECT_USER_MODIFIED_FLAG_B;
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index d3d6c3db7..28d6f90be 100644
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -1942,7 +1942,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
bool didSomething = false;
- Geom::OptRect selectionBbox = selection->bounds();
+ Geom::OptRect selectionBbox = selection->visualBounds();
if (!selectionBbox) {
return false;
}
@@ -1963,7 +1963,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
continue;
if (simplifyIndividualPaths) {
- Geom::OptRect itemBbox = item->getBounds(item->i2dt_affine());
+ Geom::OptRect itemBbox = item->desktopVisualBounds();
if (itemBbox) {
simplifySize = L2(itemBbox->dimensions());
} else {
diff --git a/src/spray-context.cpp b/src/spray-context.cpp
index 33fffb01f..68b71b21f 100644
--- a/src/spray-context.cpp
+++ b/src/spray-context.cpp
@@ -444,7 +444,7 @@ bool sp_spray_recursive(SPDesktop *desktop,
dr=dr*radius;
if (mode == SPRAY_MODE_COPY) {
- Geom::OptRect a = item->getBounds(item->i2doc_affine());
+ Geom::OptRect a = item->documentVisualBounds();
if (a) {
SPItem *item_copied;
if(_fid <= population)
@@ -496,7 +496,7 @@ bool sp_spray_recursive(SPDesktop *desktop,
Inkscape::XML::Node *old_repr = father->getRepr();
Inkscape::XML::Node *parent = old_repr->parent();
- Geom::OptRect a = father->getBounds(father->i2doc_affine());
+ Geom::OptRect a = father->documentVisualBounds();
if (a) {
if (i == 2) {
Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc);
@@ -534,7 +534,7 @@ bool sp_spray_recursive(SPDesktop *desktop,
}
}
} else if (mode == SPRAY_MODE_CLONE) {
- Geom::OptRect a = item->getBounds(item->i2doc_affine());
+ Geom::OptRect a = item->documentVisualBounds();
if (a) {
if(_fid <= population) {
SPItem *item_copied;
diff --git a/src/star-context.cpp b/src/star-context.cpp
index 878ecfbe7..c954fd7d7 100644
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -34,7 +34,6 @@
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
-#include "libnr/nr-macros.h"
#include "pixmaps/cursor-star.xpm"
#include "sp-metrics.h"
#include <glibmm/i18n.h>
diff --git a/src/svg/svg.h b/src/svg/svg.h
index d5335e1b4..de1d7d872 100644
--- a/src/svg/svg.h
+++ b/src/svg/svg.h
@@ -17,7 +17,6 @@
#include <string>
#include "svg/svg-length.h"
-#include "libnr/nr-forward.h"
#include <2geom/forward.h>
/* Generic */
diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp
index d64fa749a..a4a6b231a 100644
--- a/src/text-chemistry.cpp
+++ b/src/text-chemistry.cpp
@@ -432,8 +432,7 @@ text_unflow ()
/* Set style */
rtext->setAttribute("style", flowtext->getRepr()->attribute("style")); // fixme: transfer style attrs too; and from descendants
- Geom::OptRect bbox;
- flowtext->invoke_bbox(bbox, flowtext->i2doc_affine(), TRUE);
+ Geom::OptRect bbox = flowtext->geometricBounds(flowtext->i2doc_affine());
if (bbox) {
Geom::Point xy = bbox->min();
sp_repr_set_svg_double(rtext, "x", xy[Geom::X]);
diff --git a/src/text-context.cpp b/src/text-context.cpp
index 1468984a1..d2bf8c5f5 100644
--- a/src/text-context.cpp
+++ b/src/text-context.cpp
@@ -432,7 +432,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
} else {
SP_CTRLRECT(tc->indicator)->setColor(0x0000ff7f, false, 0);
}
- Geom::OptRect ibbox = item_ungrouped->getBboxDesktop();
+ Geom::OptRect ibbox = item_ungrouped->desktopVisualBounds();
if (ibbox) {
SP_CTRLRECT(tc->indicator)->setRectangle(*ibbox);
}
@@ -1635,7 +1635,7 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see)
SP_CTRLRECT(tc->frame)->setColor(0x0000ff7f, false, 0);
}
sp_canvas_item_show(tc->frame);
- Geom::OptRect frame_bbox = frame->getBboxDesktop();
+ Geom::OptRect frame_bbox = frame->desktopVisualBounds();
if (frame_bbox) {
SP_CTRLRECT(tc->frame)->setRectangle(*frame_bbox);
}
diff --git a/src/text-editing.h b/src/text-editing.h
index 529b25ff5..300d0b76f 100644
--- a/src/text-editing.h
+++ b/src/text-editing.h
@@ -16,7 +16,6 @@
#include <glib/gtypes.h>
#include <utility> // std::pair
#include "libnrtype/Layout-TNG.h"
-#include <libnr/nr-forward.h>
#include "text-tag-attributes.h"
class SPCSSAttr;
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index 83598d8da..5d592b83d 100644
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -442,7 +442,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
} else {
if (mode == TWEAK_MODE_MOVE) {
- Geom::OptRect a = item->getBounds(item->i2doc_affine());
+ Geom::OptRect a = item->documentVisualBounds();
if (a) {
double x = Geom::L2(a->midpoint() - p)/radius;
if (a->contains(p)) x = 0;
@@ -455,7 +455,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
} else if (mode == TWEAK_MODE_MOVE_IN_OUT) {
- Geom::OptRect a = item->getBounds(item->i2doc_affine());
+ Geom::OptRect a = item->documentVisualBounds();
if (a) {
double x = Geom::L2(a->midpoint() - p)/radius;
if (a->contains(p)) x = 0;
@@ -469,7 +469,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
} else if (mode == TWEAK_MODE_MOVE_JITTER) {
- Geom::OptRect a = item->getBounds(item->i2doc_affine());
+ Geom::OptRect a = item->documentVisualBounds();
if (a) {
double dp = g_random_double_range(0, M_PI*2);
double dr = g_random_double_range(0, radius);
@@ -484,7 +484,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
} else if (mode == TWEAK_MODE_SCALE) {
- Geom::OptRect a = item->getBounds(item->i2doc_affine());
+ Geom::OptRect a = item->documentVisualBounds();
if (a) {
double x = Geom::L2(a->midpoint() - p)/radius;
if (a->contains(p)) x = 0;
@@ -497,7 +497,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
} else if (mode == TWEAK_MODE_ROTATE) {
- Geom::OptRect a = item->getBounds(item->i2doc_affine());
+ Geom::OptRect a = item->documentVisualBounds();
if (a) {
double x = Geom::L2(a->midpoint() - p)/radius;
if (a->contains(p)) x = 0;
@@ -510,7 +510,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
} else if (mode == TWEAK_MODE_MORELESS) {
- Geom::OptRect a = item->getBounds(item->i2doc_affine());
+ Geom::OptRect a = item->documentVisualBounds();
if (a) {
double x = Geom::L2(a->midpoint() - p)/radius;
if (a->contains(p)) x = 0;
@@ -562,7 +562,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
}
// skip those paths whose bboxes are entirely out of reach with our radius
- Geom::OptRect bbox = item->getBounds(item->i2doc_affine());
+ Geom::OptRect bbox = item->documentVisualBounds();
if (bbox) {
bbox->expandBy(radius);
if (!bbox->contains(p)) {
@@ -946,8 +946,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
if (!style) {
return false;
}
- Geom::OptRect bbox = item->getBounds(item->i2doc_affine(),
- SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox = item->documentGeometricBounds();
if (!bbox) {
return false;
}
@@ -976,8 +975,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
if (this_force > 0.002) {
if (do_blur) {
- Geom::OptRect bbox = item->getBounds(item->i2doc_affine(),
- SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox = item->documentGeometricBounds();
if (!bbox) {
return did;
}
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 60379a966..bb89879fb 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -46,8 +46,6 @@
#include "extension/input.h"
#include "extension/output.h"
#include "selection-chemistry.h"
-#include "libnr/nr-rect.h"
-#include "libnr/nr-convert2geom.h"
#include <2geom/rect.h>
#include <2geom/transforms.h>
#include "box3d.h"
@@ -467,7 +465,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
if (separately) {
for (GSList *i = const_cast<GSList*>(selection->itemList()) ; i ; i = i->next) {
SPItem *item = SP_ITEM(i->data);
- Geom::OptRect obj_size = item->getBboxDesktop();
+ Geom::OptRect obj_size = item->desktopVisualBounds();
if ( !obj_size ) {
continue;
}
@@ -476,7 +474,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
}
// resize the selection as a whole
else {
- Geom::OptRect sel_size = selection->bounds();
+ Geom::OptRect sel_size = selection->visualBounds();
if ( sel_size ) {
sp_selection_scale_relative(selection, sel_size->midpoint(),
_getScale(desktop, min, max, *sel_size, apply_x, apply_y));
@@ -636,7 +634,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
}
}
- Geom::OptRect size = selection->bounds();
+ Geom::OptRect size = selection->visualBounds();
if (size) {
sp_repr_set_point(_clipnode, "min", size->min());
sp_repr_set_point(_clipnode, "max", size->max());
@@ -852,7 +850,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo
target_document->ensureUpToDate();
// move selection either to original position (in_place) or to mouse pointer
- Geom::OptRect sel_bbox = selection->bounds();
+ Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
// get offset of selection to original position of copied elements
Geom::Point pos_original;
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 8728e2ef4..36d5a20d0 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -155,7 +155,7 @@ private :
selected.erase(master);
/*}*/
//Compute the anchor point
- Geom::OptRect b = thing->getBboxDesktop ();
+ Geom::OptRect b = thing->desktopVisualBounds();
if (b) {
mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X],
a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]);
@@ -172,7 +172,7 @@ private :
case AlignAndDistribute::DRAWING:
{
- Geom::OptRect b = sp_desktop_document(desktop)->getRoot()->getBboxDesktop();
+ Geom::OptRect b = sp_desktop_document(desktop)->getRoot()->desktopVisualBounds();
if (b) {
mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X],
a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]);
@@ -184,7 +184,7 @@ private :
case AlignAndDistribute::SELECTION:
{
- Geom::OptRect b = selection->bounds();
+ Geom::OptRect b = selection->visualBounds();
if (b) {
mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X],
a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]);
@@ -211,7 +211,7 @@ private :
bool changed = false;
Geom::OptRect b;
if (sel_as_group)
- b = selection->bounds();
+ b = selection->visualBounds();
//Move each item in the selected list separately
for (std::list<SPItem *>::iterator it(selected.begin());
@@ -220,7 +220,7 @@ private :
{
sp_desktop_document (desktop)->ensureUpToDate();
if (!sel_as_group)
- b = (*it)->getBboxDesktop();
+ b = (*it)->desktopVisualBounds();
if (b) {
Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X],
a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]);
@@ -261,7 +261,7 @@ ActionAlign::Coeffs const ActionAlign::_allCoeffs[10] = {
{0., 0., 1., 0., 0., 0., 0., 1.}
};
-BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd) :
+BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect const &bounds, Geom::Dim2 orientation, double kBegin, double kEnd) :
item(pItem),
bbox (bounds)
{
@@ -324,7 +324,7 @@ private :
it != selected.end();
++it)
{
- Geom::OptRect bbox = (*it)->getBboxDesktop();
+ Geom::OptRect bbox = (*it)->desktopVisualBounds();
if (bbox) {
sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd));
}
@@ -699,7 +699,7 @@ private :
//Check 2 or more selected objects
if (selected.size() < 2) return;
- Geom::OptRect sel_bbox = selection->bounds();
+ Geom::OptRect sel_bbox = selection->visualBounds();
if (!sel_bbox) {
return;
}
@@ -721,7 +721,7 @@ private :
++it)
{
sp_desktop_document (desktop)->ensureUpToDate();
- Geom::OptRect item_box = (*it)->getBboxDesktop ();
+ Geom::OptRect item_box = (*it)->desktopVisualBounds();
if (item_box) {
// find new center, staying within bbox
double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 +
@@ -1245,7 +1245,7 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem
{
gdouble max = -1e18;
for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) {
- Geom::OptRect b = (*it)->getBboxDesktop ();
+ Geom::OptRect b = (*it)->desktopVisualBounds();
if (b) {
gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent();
if (dim > max) {
@@ -1262,7 +1262,7 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem
{
gdouble max = 1e18;
for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) {
- Geom::OptRect b = (*it)->getBboxDesktop ();
+ Geom::OptRect b = (*it)->desktopVisualBounds();
if (b) {
gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent();
if (dim < max) {
diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h
index 99b96463c..88d934f87 100644
--- a/src/ui/dialog/align-and-distribute.h
+++ b/src/ui/dialog/align-and-distribute.h
@@ -25,8 +25,6 @@
#include <gtkmm/table.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/label.h>
-#include "libnr/nr-rect.h"
-
#include "ui/widget/panel.h"
#include "ui/widget/notebook-page.h"
@@ -120,7 +118,7 @@ struct BBoxSort
SPItem *item;
float anchor;
Geom::Rect bbox;
- BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd);
+ BBoxSort(SPItem *pItem, Geom::Rect const &bounds, Geom::Dim2 orientation, double kBegin, double kEnd);
BBoxSort(const BBoxSort &rhs);
};
bool operator< (const BBoxSort &a, const BBoxSort &b);
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index 9fb1d831f..777f37e8f 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -992,10 +992,8 @@ bool FileOpenDialogImplWin32::set_svg_preview()
NRRectL bbox = {0, 0, scaledSvgWidth, scaledSvgHeight};
// write object bbox to area
- Geom::OptRect maybeArea(area);
svgDoc->ensureUpToDate();
- svgDoc->getRoot()->invoke_bbox( maybeArea,
- svgDoc->getRoot()->i2dt_affine(), TRUE);
+ Geom::OptRect maybeArea = area | svgDoc->getRoot()->desktopVisualBounds();
NRArena *const arena = NRArena::create();
diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp
index 68ad9393c..5f19a2613 100644
--- a/src/ui/dialog/tile.cpp
+++ b/src/ui/dialog/tile.cpp
@@ -47,8 +47,8 @@ sp_compare_x_position(SPItem *first, SPItem *second)
using Geom::X;
using Geom::Y;
- Geom::OptRect a = first->getBounds(first->i2doc_affine());
- Geom::OptRect b = second->getBounds(second->i2doc_affine());
+ Geom::OptRect a = first->documentVisualBounds();
+ Geom::OptRect b = second->documentVisualBounds();
if ( !a || !b ) {
// FIXME?
@@ -87,8 +87,8 @@ sp_compare_x_position(SPItem *first, SPItem *second)
int
sp_compare_y_position(SPItem *first, SPItem *second)
{
- Geom::OptRect a = first->getBounds(first->i2doc_affine());
- Geom::OptRect b = second->getBounds(second->i2doc_affine());
+ Geom::OptRect a = first->documentVisualBounds();
+ Geom::OptRect b = second->documentVisualBounds();
if ( !a || !b ) {
// FIXME?
@@ -167,7 +167,7 @@ void TileDialog::Grid_Arrange ()
cnt=0;
for (; items != NULL; items = items->next) {
SPItem *item = SP_ITEM(items->data);
- Geom::OptRect b = item->getBounds(item->i2doc_affine());
+ Geom::OptRect b = item->documentVisualBounds();
if (!b) {
continue;
}
@@ -210,7 +210,7 @@ void TileDialog::Grid_Arrange ()
const GSList *sizes = sorted;
for (; sizes != NULL; sizes = sizes->next) {
SPItem *item = SP_ITEM(sizes->data);
- Geom::OptRect b = item->getBounds(item->i2doc_affine());
+ Geom::OptRect b = item->documentVisualBounds();
if (b) {
width = b->dimensions()[Geom::X];
height = b->dimensions()[Geom::Y];
@@ -267,7 +267,7 @@ void TileDialog::Grid_Arrange ()
}
- Geom::OptRect sel_bbox = selection->bounds();
+ Geom::OptRect sel_bbox = selection->visualBounds();
// Fit to bbox, calculate padding between rows accordingly.
if ( sel_bbox && !SpaceManualRadioButton.get_active() ){
#ifdef DEBUG_GRID_ARRANGE
@@ -317,7 +317,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h
for (; current_row != NULL; current_row = current_row->next) {
SPItem *item=SP_ITEM(current_row->data);
Inkscape::XML::Node *repr = item->getRepr();
- Geom::OptRect b = item->getBounds(item->i2doc_affine());
+ Geom::OptRect b = item->documentVisualBounds();
Geom::Point min;
if (b) {
width = b->dimensions()[Geom::X];
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index 92c8bd349..029a83ea5 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -467,7 +467,7 @@ Transformation::updatePageMove(Inkscape::Selection *selection)
{
if (selection && !selection->isEmpty()) {
if (!_check_move_relative.get_active()) {
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
double x = bbox->min()[Geom::X];
double y = bbox->min()[Geom::Y];
@@ -489,7 +489,7 @@ void
Transformation::updatePageScale(Inkscape::Selection *selection)
{
if (selection && !selection->isEmpty()) {
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
double w = bbox->dimensions()[Geom::X];
double h = bbox->dimensions()[Geom::Y];
@@ -519,7 +519,7 @@ void
Transformation::updatePageSkew(Inkscape::Selection *selection)
{
if (selection && !selection->isEmpty()) {
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
double w = bbox->dimensions()[Geom::X];
double h = bbox->dimensions()[Geom::Y];
@@ -616,7 +616,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection)
if (_check_move_relative.get_active()) {
sp_selection_move_relative(selection, x, y);
} else {
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
sp_selection_move_relative(selection,
x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
@@ -637,7 +637,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection)
it != selected.end();
++it)
{
- Geom::OptRect bbox = (*it)->getBboxDesktop();
+ Geom::OptRect bbox = (*it)->desktopVisualBounds();
if (bbox) {
sorted.push_back(BBoxSort(*it, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.));
}
@@ -661,7 +661,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection)
it != selected.end();
++it)
{
- Geom::OptRect bbox = (*it)->getBboxDesktop();
+ Geom::OptRect bbox = (*it)->desktopVisualBounds();
if (bbox) {
sorted.push_back(BBoxSort(*it, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.));
}
@@ -680,7 +680,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection)
}
}
} else {
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
sp_selection_move_relative(selection,
x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
@@ -705,7 +705,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection)
Geom::Scale scale (0,0);
// the values are increments!
if (_units_scale.isAbsolute()) {
- Geom::OptRect bbox(item->getBboxDesktop());
+ Geom::OptRect bbox = item->desktopVisualBounds();
if (bbox) {
double new_width = scaleX;
if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object
@@ -723,7 +723,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection)
sp_item_scale_rel (item, scale);
}
} else {
- Geom::OptRect bbox(selection->bounds());
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
Geom::Point center(bbox->midpoint()); // use rotation center?
Geom::Scale scale (0,0);
@@ -792,7 +792,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection)
} else { // absolute displacement
double skewX = _scalar_skew_horizontal.getValue("px");
double skewY = _scalar_skew_vertical.getValue("px");
- Geom::OptRect bbox(item->getBboxDesktop());
+ Geom::OptRect bbox = item->desktopVisualBounds();
if (bbox) {
double width = bbox->dimensions()[Geom::X];
double height = bbox->dimensions()[Geom::Y];
@@ -801,7 +801,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection)
}
}
} else { // transform whole selection
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
boost::optional<Geom::Point> center = selection->center();
if ( bbox && center ) {
@@ -886,7 +886,7 @@ Transformation::onMoveRelativeToggled()
//g_message("onMoveRelativeToggled: %f, %f px\n", x, y);
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
if (_check_move_relative.get_active()) {
@@ -1026,7 +1026,7 @@ Transformation::onClear()
_scalar_move_horizontal.setValue(0);
_scalar_move_vertical.setValue(0);
} else {
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
_scalar_move_horizontal.setValue(bbox->min()[Geom::X], "px");
_scalar_move_vertical.setValue(bbox->min()[Geom::Y], "px");
diff --git a/src/ui/view/view.h b/src/ui/view/view.h
index db6061434..c56d79147 100644
--- a/src/ui/view/view.h
+++ b/src/ui/view/view.h
@@ -21,7 +21,6 @@
#include "gc-managed.h"
#include "gc-finalized.h"
#include "gc-anchored.h"
-#include <libnr/nr-forward.h>
#include <2geom/forward.h>
/**
diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp
index f4780896b..f3a8478ea 100644
--- a/src/ui/widget/style-subject.cpp
+++ b/src/ui/widget/style-subject.cpp
@@ -147,7 +147,7 @@ StyleSubject::iterator StyleSubject::CurrentLayer::begin() {
Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) {
SPObject *layer = _getLayer();
if (layer && SP_IS_ITEM(layer)) {
- return SP_ITEM(layer)->getBboxDesktop(type);
+ return SP_ITEM(layer)->desktopBounds(type);
} else {
return Geom::OptRect();
}
diff --git a/src/ui/widget/style-subject.h b/src/ui/widget/style-subject.h
index 6d5c96350..29684ec02 100644
--- a/src/ui/widget/style-subject.h
+++ b/src/ui/widget/style-subject.h
@@ -11,7 +11,6 @@
#include "util/glib-list-iterators.h"
#include <boost/optional.hpp>
-#include "libnr/nr-rect.h"
#include <2geom/rect.h>
#include "sp-item.h"
#include <stddef.h>
@@ -45,7 +44,7 @@ public:
virtual iterator begin() = 0;
virtual iterator end() { return iterator(NULL); }
- virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) = 0;
+ virtual Geom::OptRect getBounds(SPItem::BBoxType type) = 0;
virtual int queryStyle(SPStyle *query, int property) = 0;
virtual void setCSS(SPCSSAttr *css) = 0;
@@ -68,7 +67,7 @@ public:
~Selection();
virtual iterator begin();
- virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
+ virtual Geom::OptRect getBounds(SPItem::BBoxType type);
virtual int queryStyle(SPStyle *query, int property);
virtual void setCSS(SPCSSAttr *css);
@@ -89,7 +88,7 @@ public:
~CurrentLayer();
virtual iterator begin();
- virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
+ virtual Geom::OptRect getBounds(SPItem::BBoxType type);
virtual int queryStyle(SPStyle *query, int property);
virtual void setCSS(SPCSSAttr *css);
diff --git a/src/ui/widget/zoom-status.cpp b/src/ui/widget/zoom-status.cpp
index 9322aa803..c6d6f19a3 100644
--- a/src/ui/widget/zoom-status.cpp
+++ b/src/ui/widget/zoom-status.cpp
@@ -20,7 +20,6 @@
#include "desktop.h"
#include "desktop-handles.h"
#include "widgets/spw-utilities.h"
-#include "libnr/nr-convert2geom.h"
namespace Inkscape {
namespace UI {
diff --git a/src/unclump.cpp b/src/unclump.cpp
index e570e8fa7..6b9a8c574 100644
--- a/src/unclump.cpp
+++ b/src/unclump.cpp
@@ -34,7 +34,7 @@ unclump_center (SPItem *item)
return i->second;
}
- Geom::OptRect r = item->getBounds(item->i2dt_affine());
+ Geom::OptRect r = item->desktopVisualBounds();
if (r) {
Geom::Point const c = r->midpoint();
c_cache[item->getId()] = c;
@@ -53,7 +53,7 @@ unclump_wh (SPItem *item)
if ( i != wh_cache.end() ) {
wh = i->second;
} else {
- Geom::OptRect r = item->getBounds(item->i2dt_affine());
+ Geom::OptRect r = item->desktopVisualBounds();
if (r) {
wh = r->dimensions();
wh_cache[item->getId()] = wh;
diff --git a/src/verbs.cpp b/src/verbs.cpp
index e443e9917..43d100138 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -118,8 +118,7 @@ namespace Inkscape {
file operations. */
class FileVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -137,8 +136,7 @@ public:
edit operations. */
class EditVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -156,8 +154,7 @@ public:
selection operations. */
class SelectionVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -175,8 +172,7 @@ public:
layer operations. */
class LayerVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -194,8 +190,7 @@ public:
operations related to objects. */
class ObjectVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -213,8 +208,7 @@ public:
operations relative to context. */
class ContextVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -232,8 +226,7 @@ public:
zoom operations. */
class ZoomVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -252,8 +245,7 @@ public:
dialog operations. */
class DialogVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -271,8 +263,7 @@ public:
help operations. */
class HelpVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -290,8 +281,7 @@ public:
tutorial operations. */
class TutorialVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -309,8 +299,7 @@ public:
text operations. */
class TextVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -363,9 +352,7 @@ Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *im
Verb::~Verb(void)
{
/// \todo all the actions need to be cleaned up first.
- if (_actions != NULL) {
- delete _actions;
- }
+ delete _actions;
if (_full_tip) {
g_free(_full_tip);
@@ -395,8 +382,8 @@ Verb::make_action(Inkscape::UI::View::View */*view*/)
SPAction *
FileVerb::make_action(Inkscape::UI::View::View *view)
{
- //std::cout << "fileverb: make_action: " << &vector << std::endl;
- return make_action_helper(view, &vector);
+ //std::cout << "fileverb: make_action: " << &perform << std::endl;
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c EditVerb
@@ -408,8 +395,8 @@ FileVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
EditVerb::make_action(Inkscape::UI::View::View *view)
{
- //std::cout << "editverb: make_action: " << &vector << std::endl;
- return make_action_helper(view, &vector);
+ //std::cout << "editverb: make_action: " << &perform << std::endl;
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c SelectionVerb
@@ -421,7 +408,7 @@ EditVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
SelectionVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c LayerVerb
@@ -433,7 +420,7 @@ SelectionVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
LayerVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c ObjectVerb
@@ -445,7 +432,7 @@ LayerVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
ObjectVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c ContextVerb
@@ -457,7 +444,7 @@ ObjectVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
ContextVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c ZoomVerb
@@ -469,7 +456,7 @@ ContextVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
ZoomVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c DialogVerb
@@ -481,7 +468,7 @@ ZoomVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
DialogVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c HelpVerb
@@ -493,7 +480,7 @@ DialogVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
HelpVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c TutorialVerb
@@ -505,7 +492,7 @@ HelpVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
TutorialVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Create an action for a \c TextVerb
@@ -517,7 +504,7 @@ TutorialVerb::make_action(Inkscape::UI::View::View *view)
SPAction *
TextVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief A quick little convience function to make building actions
@@ -534,7 +521,7 @@ TextVerb::make_action(Inkscape::UI::View::View *view)
the vector that is passed in.
*/
SPAction *
-Verb::make_action_helper(Inkscape::UI::View::View *view, SPActionEventVector *vector, void *in_pntr)
+Verb::make_action_helper(Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr)
{
SPAction *action;
@@ -542,23 +529,14 @@ Verb::make_action_helper(Inkscape::UI::View::View *view, SPActionEventVector *ve
action = sp_action_new(view, _id, _(_name),
_(_tip), _image, this);
- if (action != NULL) {
- if (in_pntr == NULL) {
- nr_active_object_add_listener(
- (NRActiveObject *) action,
- (NRObjectEventVector *) vector,
- sizeof(SPActionEventVector),
- reinterpret_cast<void *>(_code)
- );
- } else {
- nr_active_object_add_listener(
- (NRActiveObject *) action,
- (NRObjectEventVector *) vector,
- sizeof(SPActionEventVector),
- in_pntr
- );
- }
- }
+ if (action == NULL) return NULL;
+
+ action->signal_perform.connect(
+ sigc::bind(
+ sigc::bind(
+ sigc::ptr_fun(perform_fun),
+ in_pntr ? in_pntr : reinterpret_cast<void*>(_code)),
+ action));
return action;
}
@@ -703,8 +681,8 @@ Verb::delete_view(Inkscape::UI::View::View *view)
if (action_found != _actions->end()) {
SPAction *action = action_found->second;
- nr_object_unref(NR_OBJECT(action));
_actions->erase(action_found);
+ g_object_unref(action);
}
return;
@@ -785,7 +763,7 @@ Verb::getbyid(gchar const *id)
/** \brief Decode the verb code and take appropriate action */
void
-FileVerb::perform(SPAction *action, void *data, void */*pdata*/)
+FileVerb::perform(SPAction *action, void *data)
{
#if 0
/* These aren't used, but are here to remind people not to use
@@ -857,7 +835,7 @@ FileVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
+EditVerb::perform(SPAction *action, void *data)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
if (!dt)
@@ -988,7 +966,7 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-SelectionVerb::perform(SPAction *action, void *data, void */*pdata*/)
+SelectionVerb::perform(SPAction *action, void *data)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
@@ -1108,7 +1086,7 @@ SelectionVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
+LayerVerb::perform(SPAction *action, void *data)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
size_t verb = reinterpret_cast<std::size_t>(data);
@@ -1312,7 +1290,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
+ObjectVerb::perform( SPAction *action, void *data)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
if (!dt)
@@ -1325,7 +1303,7 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
if (sel->isEmpty())
return;
- Geom::OptRect bbox = sel->bounds();
+ Geom::OptRect bbox = sel->visualBounds();
if (!bbox) {
return;
}
@@ -1395,7 +1373,7 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
/** \brief Decode the verb code and take appropriate action */
void
-ContextVerb::perform(SPAction *action, void *data, void */*pdata*/)
+ContextVerb::perform(SPAction *action, void *data)
{
SPDesktop *dt;
sp_verb_t verb;
@@ -1579,7 +1557,7 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-TextVerb::perform(SPAction *action, void */*data*/, void */*pdata*/)
+TextVerb::perform(SPAction *action, void */*data*/)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
if (!dt)
@@ -1593,7 +1571,7 @@ TextVerb::perform(SPAction *action, void */*data*/, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/)
+ZoomVerb::perform(SPAction *action, void *data)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
if (!dt)
@@ -1754,7 +1732,7 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-DialogVerb::perform(SPAction *action, void *data, void */*pdata*/)
+DialogVerb::perform(SPAction *action, void *data)
{
if (reinterpret_cast<std::size_t>(data) != SP_VERB_DIALOG_TOGGLE) {
// unhide all when opening a new dialog
@@ -1866,7 +1844,7 @@ DialogVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-HelpVerb::perform(SPAction *action, void *data, void */*pdata*/)
+HelpVerb::perform(SPAction *action, void *data)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
g_assert(dt->_dlg_mgr != NULL);
@@ -1900,7 +1878,7 @@ HelpVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief Decode the verb code and take appropriate action */
void
-TutorialVerb::perform(SPAction */*action*/, void *data, void */*pdata*/)
+TutorialVerb::perform(SPAction */*action*/, void *data)
{
switch (reinterpret_cast<std::size_t>(data)) {
case SP_VERB_TUTORIAL_BASIC:
@@ -1942,92 +1920,12 @@ TutorialVerb::perform(SPAction */*action*/, void *data, void */*pdata*/)
}
} // end of sp_verb_action_tutorial_perform()
-
-/**
- * Action vector to define functions called if a staticly defined file verb
- * is called.
- */
-SPActionEventVector FileVerb::vector =
- {{NULL},FileVerb::perform, NULL, NULL, NULL, NULL};
-/**
- * Action vector to define functions called if a staticly defined edit verb is
- * called.
- */
-SPActionEventVector EditVerb::vector =
- {{NULL},EditVerb::perform, NULL, NULL, NULL, NULL};
-
-/**
- * Action vector to define functions called if a staticly defined selection
- * verb is called
- */
-SPActionEventVector SelectionVerb::vector =
- {{NULL},SelectionVerb::perform, NULL, NULL, NULL, NULL};
-
-/**
- * Action vector to define functions called if a staticly defined layer
- * verb is called
- */
-SPActionEventVector LayerVerb::vector =
- {{NULL}, LayerVerb::perform, NULL, NULL, NULL, NULL};
-
-/**
- * Action vector to define functions called if a staticly defined object
- * editing verb is called
- */
-SPActionEventVector ObjectVerb::vector =
- {{NULL},ObjectVerb::perform, NULL, NULL, NULL, NULL};
-
-/**
- * Action vector to define functions called if a staticly defined context
- * verb is called
- */
-SPActionEventVector ContextVerb::vector =
- {{NULL},ContextVerb::perform, NULL, NULL, NULL, NULL};
-
-/**
- * Action vector to define functions called if a staticly defined zoom verb
- * is called
- */
-SPActionEventVector ZoomVerb::vector =
- {{NULL},ZoomVerb::perform, NULL, NULL, NULL, NULL};
-
-
-/**
- * Action vector to define functions called if a staticly defined dialog verb
- * is called
- */
-SPActionEventVector DialogVerb::vector =
- {{NULL},DialogVerb::perform, NULL, NULL, NULL, NULL};
-
-/**
- * Action vector to define functions called if a staticly defined help verb
- * is called
- */
-SPActionEventVector HelpVerb::vector =
- {{NULL},HelpVerb::perform, NULL, NULL, NULL, NULL};
-
-/**
- * Action vector to define functions called if a staticly defined tutorial verb
- * is called
- */
-SPActionEventVector TutorialVerb::vector =
- {{NULL},TutorialVerb::perform, NULL, NULL, NULL, NULL};
-
-/**
- * Action vector to define functions called if a staticly defined tutorial verb
- * is called
- */
-SPActionEventVector TextVerb::vector =
- {{NULL},TextVerb::perform, NULL, NULL, NULL, NULL};
-
-
/* *********** Effect Last ********** */
/** \brief A class to represent the last effect issued */
class EffectLastVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -2043,12 +1941,6 @@ public:
}
}; /* EffectLastVerb class */
-/**
- * The vector to attach in the last effect verb.
- */
-SPActionEventVector EffectLastVerb::vector =
- {{NULL},EffectLastVerb::perform, NULL, NULL, NULL, NULL};
-
/** \brief Create an action for a \c EffectLastVerb
\param view Which view the action should be created for
\return The built action.
@@ -2058,12 +1950,12 @@ SPActionEventVector EffectLastVerb::vector =
SPAction *
EffectLastVerb::make_action(Inkscape::UI::View::View *view)
{
- return make_action_helper(view, &vector);
+ return make_action_helper(view, &perform);
}
/** \brief Decode the verb code and take appropriate action */
void
-EffectLastVerb::perform(SPAction *action, void *data, void */*pdata*/)
+EffectLastVerb::perform(SPAction *action, void *data)
{
/* These aren't used, but are here to remind people not to use
the CURRENT_DOCUMENT macros unless they really have to. */
@@ -2094,8 +1986,7 @@ EffectLastVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief A class to represent the canvas fitting verbs */
class FitCanvasVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -2111,12 +2002,6 @@ public:
}
}; /* FitCanvasVerb class */
-/**
- * The vector to attach in the fit canvas verb.
- */
-SPActionEventVector FitCanvasVerb::vector =
- {{NULL},FitCanvasVerb::perform, NULL, NULL, NULL, NULL};
-
/** \brief Create an action for a \c FitCanvasVerb
\param view Which view the action should be created for
\return The built action.
@@ -2126,13 +2011,13 @@ SPActionEventVector FitCanvasVerb::vector =
SPAction *
FitCanvasVerb::make_action(Inkscape::UI::View::View *view)
{
- SPAction *action = make_action_helper(view, &vector);
+ SPAction *action = make_action_helper(view, &perform);
return action;
}
/** \brief Decode the verb code and take appropriate action */
void
-FitCanvasVerb::perform(SPAction *action, void *data, void */*pdata*/)
+FitCanvasVerb::perform(SPAction *action, void *data)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
if (!dt) return;
@@ -2163,8 +2048,7 @@ FitCanvasVerb::perform(SPAction *action, void *data, void */*pdata*/)
/** \brief A class to represent the object unlocking and unhiding verbs */
class LockAndHideVerb : public Verb {
private:
- static void perform(SPAction *action, void *mydata, void *otherdata);
- static SPActionEventVector vector;
+ static void perform(SPAction *action, void *mydata);
protected:
virtual SPAction *make_action(Inkscape::UI::View::View *view);
public:
@@ -2180,12 +2064,6 @@ public:
}
}; /* LockAndHideVerb class */
-/**
- * The vector to attach in the lock'n'hide verb.
- */
-SPActionEventVector LockAndHideVerb::vector =
- {{NULL},LockAndHideVerb::perform, NULL, NULL, NULL, NULL};
-
/** \brief Create an action for a \c LockAndHideVerb
\param view Which view the action should be created for
\return The built action.
@@ -2195,13 +2073,13 @@ SPActionEventVector LockAndHideVerb::vector =
SPAction *
LockAndHideVerb::make_action(Inkscape::UI::View::View *view)
{
- SPAction *action = make_action_helper(view, &vector);
+ SPAction *action = make_action_helper(view, &perform);
return action;
}
/** \brief Decode the verb code and take appropriate action */
void
-LockAndHideVerb::perform(SPAction *action, void *data, void */*pdata*/)
+LockAndHideVerb::perform(SPAction *action, void *data)
{
SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
if (!dt) return;
diff --git a/src/verbs.h b/src/verbs.h
index d20189cde..224a809b0 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -403,8 +403,8 @@ public:
gchar const * set_tip (gchar const * tip) { _tip = tip; return _tip; }
protected:
- SPAction * make_action_helper (Inkscape::UI::View::View * view, SPActionEventVector * vector, void * in_pntr = NULL);
- virtual SPAction * make_action (Inkscape::UI::View::View * view);
+ SPAction *make_action_helper (Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr = NULL);
+ virtual SPAction *make_action (Inkscape::UI::View::View *view);
public:
/** \brief Inititalizes the Verb with the parameters
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index e0b3a0fb9..1360e0a30 100644
--- a/src/widgets/button.cpp
+++ b/src/widgets/button.cpp
@@ -43,20 +43,10 @@ static gint sp_button_process_event (SPButton *button, GdkEvent *event);
static void sp_button_set_action (SPButton *button, SPAction *action);
static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action);
-static void sp_button_action_set_active (SPAction *action, unsigned int active, void *data);
-static void sp_button_action_set_sensitive (SPAction *action, unsigned int sensitive, void *data);
-static void sp_button_action_set_shortcut (SPAction *action, unsigned int shortcut, void *data);
+static void sp_button_action_set_active (SPButton *button, bool active);
static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action);
static GtkToggleButtonClass *parent_class;
-SPActionEventVector button_event_vector = {
- {NULL},
- NULL,
- sp_button_action_set_active,
- sp_button_action_set_sensitive,
- sp_button_action_set_shortcut,
- NULL
-};
GType sp_button_get_type(void)
{
@@ -98,6 +88,8 @@ sp_button_init (SPButton *button)
{
button->action = NULL;
button->doubleclick_action = NULL;
+ new (&button->c_set_active) sigc::connection();
+ new (&button->c_set_sensitive) sigc::connection();
gtk_container_set_border_width (GTK_CONTAINER (button), 0);
@@ -111,18 +103,18 @@ sp_button_init (SPButton *button)
static void
sp_button_destroy (GtkObject *object)
{
- SPButton *button;
-
- button = SP_BUTTON (object);
+ SPButton *button = SP_BUTTON (object);
if (button->action) {
sp_button_set_action (button, NULL);
}
-
if (button->doubleclick_action) {
sp_button_set_doubleclick_action (button, NULL);
}
+ button->c_set_active.~connection();
+ button->c_set_sensitive.~connection();
+
((GtkObjectClass *) (parent_class))->destroy (object);
}
@@ -212,12 +204,13 @@ static void
sp_button_set_doubleclick_action (SPButton *button, SPAction *action)
{
if (button->doubleclick_action) {
- nr_object_unref ((NRObject *) button->doubleclick_action);
+ g_object_unref (button->doubleclick_action);
}
button->doubleclick_action = action;
if (action) {
- button->doubleclick_action = (SPAction *) nr_object_ref ((NRObject *) action);
+ g_object_ref(action);
}
+
}
static void
@@ -226,17 +219,25 @@ sp_button_set_action (SPButton *button, SPAction *action)
GtkWidget *child;
if (button->action) {
- nr_active_object_remove_listener_by_data ((NRActiveObject *) button->action, button);
- nr_object_unref ((NRObject *) button->action);
+ button->c_set_active.disconnect();
+ button->c_set_sensitive.disconnect();
child = gtk_bin_get_child (GTK_BIN (button));
if (child) {
gtk_container_remove (GTK_CONTAINER (button), child);
}
+ g_object_unref(button->action);
}
button->action = action;
if (action) {
- button->action = (SPAction *) nr_object_ref ((NRObject *) action);
- nr_active_object_add_listener ((NRActiveObject *) action, (NRObjectEventVector *) &button_event_vector, sizeof (SPActionEventVector), button);
+ g_object_ref(action);
+ button->c_set_active = action->signal_set_active.connect(
+ sigc::bind<0>(
+ sigc::ptr_fun(&sp_button_action_set_active),
+ SP_BUTTON(button)));
+ button->c_set_sensitive = action->signal_set_sensitive.connect(
+ sigc::bind<0>(
+ sigc::ptr_fun(&gtk_widget_set_sensitive),
+ GTK_WIDGET(button)));
if (action->image) {
child = sp_icon_new (button->lsize, action->image);
gtk_widget_show (child);
@@ -248,10 +249,8 @@ sp_button_set_action (SPButton *button, SPAction *action)
}
static void
-sp_button_action_set_active (SPAction */*action*/, unsigned int active, void *data)
+sp_button_action_set_active (SPButton *button, bool active)
{
- SPButton *button;
- button = (SPButton *) data;
if (button->type != SP_BUTTON_TYPE_TOGGLE) {
return;
}
@@ -262,19 +261,6 @@ sp_button_action_set_active (SPAction */*action*/, unsigned int active, void *da
}
}
-static void
-sp_button_action_set_sensitive (SPAction */*action*/, unsigned int sensitive, void *data)
-{
- gtk_widget_set_sensitive (GTK_WIDGET (data), sensitive);
-}
-
-static void
-sp_button_action_set_shortcut (SPAction *action, unsigned int /*shortcut*/, void *data)
-{
- SPButton *button=SP_BUTTON (data);
- sp_button_set_composed_tooltip (GTK_WIDGET (button), action);
-}
-
static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action)
{
if (action) {
@@ -308,7 +294,7 @@ sp_button_new_from_data( Inkscape::IconSize size,
GtkWidget *button;
SPAction *action=sp_action_new(view, name, name, tip, name, 0);
button = sp_button_new (size, type, action, NULL);
- nr_object_unref ((NRObject *) action);
+ g_object_unref(action);
return button;
}
diff --git a/src/widgets/button.h b/src/widgets/button.h
index 759096443..41863357d 100644
--- a/src/widgets/button.h
+++ b/src/widgets/button.h
@@ -17,7 +17,7 @@
#define SP_IS_BUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_BUTTON))
#include <gtk/gtk.h>
-
+#include <sigc++/sigc++.h>
#include "helper/action.h"
#include "icon-size.h"
@@ -38,6 +38,9 @@ struct SPButton {
unsigned int psize;
SPAction *action;
SPAction *doubleclick_action;
+
+ sigc::connection c_set_active;
+ sigc::connection c_set_sensitive;
};
struct SPButtonClass {
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 08f0eadfb..cbfb8fe5f 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -731,15 +731,11 @@ sp_desktop_widget_realize (GtkWidget *widget)
if (GTK_WIDGET_CLASS (dtw_parent_class)->realize)
(* GTK_WIDGET_CLASS (dtw_parent_class)->realize) (widget);
- NRRect d;
- d.x0 = 0.0;
- d.y0 = 0.0;
- d.x1 = (dtw->desktop->doc())->getWidth ();
- d.y1 = (dtw->desktop->doc())->getHeight ();
+ Geom::Rect d = Geom::Rect::from_xywh(Geom::Point(0,0), (dtw->desktop->doc())->getDimensions());
- if ((fabs (d.x1 - d.x0) < 1.0) || (fabs (d.y1 - d.y0) < 1.0)) return;
+ if (d.width() < 1.0 || d.height() < 1.0) return;
- dtw->desktop->set_display_area (d.x0, d.y0, d.x1, d.y1, 10);
+ dtw->desktop->set_display_area (d.left(), d.top(), d.right(), d.bottom(), 10);
dtw->updateNamedview();
}
@@ -1881,7 +1877,7 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale)
Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()),
Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight()) );
- Geom::OptRect deskarea = darea | doc->getRoot()->getBboxDesktop();
+ Geom::OptRect deskarea = darea | doc->getRoot()->desktopVisualBounds();
/* Canvas region we always show unconditionally */
Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64),
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index a57b56b5c..9540b59d6 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -1102,8 +1102,7 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing,
if (object && SP_IS_ITEM(object)) {
SPItem *item = SP_ITEM(object);
// Find bbox in document
- Geom::Affine const i2doc(item->i2doc_affine());
- Geom::OptRect dbox = item->getBounds(i2doc);
+ Geom::OptRect dbox = item->documentVisualBounds();
if ( object->parent == NULL )
{
diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h
index ebcac380f..f32c2c83d 100644
--- a/src/widgets/paint-selector.h
+++ b/src/widgets/paint-selector.h
@@ -14,8 +14,11 @@
*/
#include <glib.h>
+#include <gtk/gtk.h>
+#include "color.h"
#include "fill-or-stroke.h"
+#include "forward.h"
#include "sp-gradient-spread.h"
#include "sp-gradient-units.h"
@@ -27,13 +30,6 @@ class SPGradient;
#define SP_IS_PAINT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_PAINT_SELECTOR))
#define SP_IS_PAINT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_PAINT_SELECTOR))
-#include <gtk/gtk.h>
-
-#include "../forward.h"
-#include <color.h>
-#include <libnr/nr-forward.h>
-
-
/// Generic paint selector widget
struct SPPaintSelector {
GtkVBox vbox;
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 260c09c69..5f90a8997 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -70,7 +70,7 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
if ( sel && !sel->isEmpty() ) {
int prefs_bbox = prefs->getInt("/tools/bounding_box", 0);
SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
Geom::OptRect const bbox(sel->bounds(bbox_type));
if ( bbox ) {
UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(G_OBJECT(spw), "tracker"));
@@ -160,12 +160,12 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
document->ensureUpToDate ();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Geom::OptRect bbox_vis = selection->bounds(SPItem::APPROXIMATE_BBOX);
- Geom::OptRect bbox_geom = selection->bounds(SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox_vis = selection->visualBounds();
+ Geom::OptRect bbox_geom = selection->geometricBounds();
int prefs_bbox = prefs->getInt("/tools/bounding_box");
SPItem::BBoxType bbox_type = (prefs_bbox == 0)?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
Geom::OptRect bbox_user = selection->bounds(bbox_type);
if ( !bbox_user ) {
@@ -247,10 +247,10 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0;
Geom::Affine scaler;
- if (bbox_type == SPItem::APPROXIMATE_BBOX) {
+ if (bbox_type == SPItem::VISUAL_BBOX) {
scaler = get_scale_transform_with_unequal_stroke (*bbox_vis, *bbox_geom, transform_stroke, x0, y0, x1, y1);
} else {
- // get_scale_transform_with_stroke() is intended for VISUAL (or APPROXIMATE) bounding boxes, not geometrical ones!
+ // get_scale_transform_with_stroke() is intended for visual bounding boxes, not geometrical ones!
// we'll trick it into using a geometric bounding box though, by setting the stroke width to zero
scaler = get_scale_transform_with_uniform_stroke (*bbox_user, 0, false, x0, y0, x1, y1);
}
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 8d9b9b429..bb9391c78 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -191,8 +191,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
SPItem *item = SP_ITEM(object);
// Find object's bbox in document
- Geom::Affine const i2doc(item->i2doc_affine());
- Geom::OptRect dbox = item->getBounds(i2doc);
+ Geom::OptRect dbox = item->documentVisualBounds();
if (!dbox) {
return NULL;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index d2753fadf..0b37aa610 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -863,23 +863,6 @@ static void trigger_sp_action( GtkAction* /*act*/, gpointer user_data )
}
}
-static void sp_action_action_set_sensitive(SPAction * /*action*/, unsigned int sensitive, void *data)
-{
- if ( data ) {
- GtkAction* act = GTK_ACTION(data);
- gtk_action_set_sensitive( act, sensitive );
- }
-}
-
-static SPActionEventVector action_event_vector = {
- {NULL},
- NULL,
- NULL,
- sp_action_action_set_sensitive,
- NULL,
- NULL
-};
-
static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::View::View* view, Inkscape::IconSize size )
{
GtkAction* act = 0;
@@ -891,8 +874,13 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi
g_signal_connect( G_OBJECT(inky), "activate", G_CALLBACK(trigger_sp_action), targetAction );
- SPAction*rebound = dynamic_cast<SPAction *>( nr_object_ref( dynamic_cast<NRObject *>(targetAction) ) );
- nr_active_object_add_listener( (NRActiveObject *)rebound, (NRObjectEventVector *)&action_event_vector, sizeof(SPActionEventVector), inky );
+ // FIXME: memory leak: this is not unrefed anywhere
+ g_object_ref(G_OBJECT(targetAction));
+ g_object_set_data_full(G_OBJECT(inky), "SPAction", (void*) targetAction, (GDestroyNotify) &g_object_unref);
+ targetAction->signal_set_sensitive.connect(
+ sigc::bind<0>(
+ sigc::ptr_fun(&gtk_action_set_sensitive),
+ GTK_ACTION(inky)));
return act;
}
@@ -5950,7 +5938,7 @@ static void lpetool_toggle_set_bbox(GtkToggleAction *act, gpointer data)
SPDesktop *desktop = static_cast<SPDesktop *>(data);
Inkscape::Selection *selection = desktop->selection;
- Geom::OptRect bbox = selection->bounds();
+ Geom::OptRect bbox = selection->visualBounds();
if (bbox) {
Geom::Point A(bbox->min());
@@ -6798,8 +6786,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
axis = Geom::Y;
}
- Geom::OptRect bbox
- = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox = item->geometricBounds();
if (!bbox)
continue;
double width = bbox->dimensions()[axis];