summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoshua L. Blocher <verbalshadow@gmail.com>2008-11-28 22:33:23 +0000
committerverbalshadow <verbalshadow@users.sourceforge.net>2008-11-28 22:33:23 +0000
commitad5c3f2ab7b02b3d913bf86d440590c93aae5a23 (patch)
tree8a3ba9f25a15735ef07c6d693bbaea86fad55869 /src
parentbug #168370 (consider parent transform and viewBox) (diff)
downloadinkscape-ad5c3f2ab7b02b3d913bf86d440590c93aae5a23.tar.gz
inkscape-ad5c3f2ab7b02b3d913bf86d440590c93aae5a23.zip
NR->Geom conversion of some text functions and tweak-context
(bzr r6915)
Diffstat (limited to 'src')
-rw-r--r--src/sp-text.cpp50
-rw-r--r--src/text-tag-attributes.h8
-rw-r--r--src/tweak-context.cpp52
-rw-r--r--src/tweak-context.h2
4 files changed, 56 insertions, 56 deletions
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index eae9dd088..6c2a5264a 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -590,7 +590,7 @@ void SPText::rebuildLayout()
if (tspan->role == SP_TSPAN_ROLE_UNSPECIFIED) continue;
if (!tspan->attributes.singleXYCoordinates()) continue;
Inkscape::Text::Layout::iterator iter = layout.sourceToIterator(tspan);
- NR::Point anchor_point = layout.chunkAnchorPoint(iter);
+ Geom::Point anchor_point = layout.chunkAnchorPoint(iter);
tspan->attributes.setFirstXY(anchor_point);
}
}
@@ -718,17 +718,17 @@ bool TextTagAttributes::anyAttributesSet() const
return !attributes.x.empty() || !attributes.y.empty() || !attributes.dx.empty() || !attributes.dy.empty() || !attributes.rotate.empty();
}
-NR::Point TextTagAttributes::firstXY() const
+Geom::Point TextTagAttributes::firstXY() const
{
- NR::Point point;
- if (attributes.x.empty()) point[NR::X] = 0.0;
- else point[NR::X] = attributes.x[0].computed;
- if (attributes.y.empty()) point[NR::Y] = 0.0;
- else point[NR::Y] = attributes.y[0].computed;
+ Geom::Point point;
+ if (attributes.x.empty()) point[Geom::X] = 0.0;
+ else point[Geom::X] = attributes.x[0].computed;
+ if (attributes.y.empty()) point[Geom::Y] = 0.0;
+ else point[Geom::Y] = attributes.y[0].computed;
return point;
}
-void TextTagAttributes::setFirstXY(NR::Point &point)
+void TextTagAttributes::setFirstXY(Geom::Point &point)
{
SVGLength zero_length;
zero_length = 0.0;
@@ -737,8 +737,8 @@ void TextTagAttributes::setFirstXY(NR::Point &point)
attributes.x.resize(1, zero_length);
if (attributes.y.empty())
attributes.y.resize(1, zero_length);
- attributes.x[0].computed = point[NR::X];
- attributes.y[0].computed = point[NR::Y];
+ attributes.x[0].computed = point[Geom::X];
+ attributes.y[0].computed = point[Geom::Y];
}
void TextTagAttributes::mergeInto(Inkscape::Text::Layout::OptionalTextTagAttrs *output, Inkscape::Text::Layout::OptionalTextTagAttrs const &parent_attrs, unsigned parent_attrs_offset, bool copy_xy, bool copy_dxdyrotate) const
@@ -878,7 +878,7 @@ void TextTagAttributes::joinSingleAttribute(std::vector<SVGLength> *dest_vector,
}
}
-void TextTagAttributes::transform(NR::Matrix const &matrix, double scale_x, double scale_y, bool extend_zero_length)
+void TextTagAttributes::transform(Geom::Matrix const &matrix, double scale_x, double scale_y, bool extend_zero_length)
{
SVGLength zero_length;
zero_length = 0.0;
@@ -892,22 +892,22 @@ void TextTagAttributes::transform(NR::Matrix const &matrix, double scale_x, doub
points_count = 1;
for (unsigned i = 0 ; i < points_count ; i++) {
NR::Point point;
- if (i < attributes.x.size()) point[NR::X] = attributes.x[i].computed;
+ if (i < attributes.x.size()) point[Geom::X] = attributes.x[i].computed;
else point[NR::X] = 0.0;
- if (i < attributes.y.size()) point[NR::Y] = attributes.y[i].computed;
- else point[NR::Y] = 0.0;
+ if (i < attributes.y.size()) point[Geom::Y] = attributes.y[i].computed;
+ else point[Geom::Y] = 0.0;
point *= matrix;
if (i < attributes.x.size())
- attributes.x[i] = point[NR::X];
- else if (point[NR::X] != 0.0 && extend_zero_length) {
+ attributes.x[i] = point[Geom::X];
+ else if (point[Geom::X] != 0.0 && extend_zero_length) {
attributes.x.resize(i + 1, zero_length);
- attributes.x[i] = point[NR::X];
+ attributes.x[i] = point[Geom::X];
}
if (i < attributes.y.size())
- attributes.y[i] = point[NR::Y];
- else if (point[NR::Y] != 0.0 && extend_zero_length) {
+ attributes.y[i] = point[Geom::Y];
+ else if (point[Geom::Y] != 0.0 && extend_zero_length) {
attributes.y.resize(i + 1, zero_length);
- attributes.y[i] = point[NR::Y];
+ attributes.y[i] = point[Geom::Y];
}
}
for (std::vector<SVGLength>::iterator it = attributes.dx.begin() ; it != attributes.dx.end() ; it++)
@@ -916,18 +916,18 @@ void TextTagAttributes::transform(NR::Matrix const &matrix, double scale_x, doub
*it = it->computed * scale_y;
}
-void TextTagAttributes::addToDxDy(unsigned index, NR::Point const &adjust)
+void TextTagAttributes::addToDxDy(unsigned index, Geom::Point const &adjust)
{
SVGLength zero_length;
zero_length = 0.0;
- if (adjust[NR::X] != 0.0) {
+ if (adjust[Geom::X] != 0.0) {
if (attributes.dx.size() < index + 1) attributes.dx.resize(index + 1, zero_length);
- attributes.dx[index] = attributes.dx[index].computed + adjust[NR::X];
+ attributes.dx[index] = attributes.dx[index].computed + adjust[Geom::X];
}
- if (adjust[NR::Y] != 0.0) {
+ if (adjust[Geom::Y] != 0.0) {
if (attributes.dy.size() < index + 1) attributes.dy.resize(index + 1, zero_length);
- attributes.dy[index] = attributes.dy[index].computed + adjust[NR::Y];
+ attributes.dy[index] = attributes.dy[index].computed + adjust[Geom::Y];
}
}
diff --git a/src/text-tag-attributes.h b/src/text-tag-attributes.h
index 9c1425dff..7a7ba5763 100644
--- a/src/text-tag-attributes.h
+++ b/src/text-tag-attributes.h
@@ -88,11 +88,11 @@ public:
If \a extend_zero_length is true, then if the x or y vectors are empty
they will be made length 1 in order to store the newly calculated
position. */
- void transform(NR::Matrix const &matrix, double scale_x, double scale_y, bool extend_zero_length = false);
+ void transform(Geom::Matrix const &matrix, double scale_x, double scale_y, bool extend_zero_length = false);
/** Adds the given values to the dx and dy vectors at the given
\a index. The vectors are extended if necessary. */
- void addToDxDy(unsigned index, NR::Point const &adjust);
+ void addToDxDy(unsigned index, Geom::Point const &adjust);
/** Adds the given value to the rotate vector at the given \a index. The
vector is extended if necessary. Delta is measured in degrees, clockwise
@@ -101,10 +101,10 @@ public:
/** Returns the first coordinates in the x and y vectors. If either
is zero length, 0.0 is used for that coordinate. */
- NR::Point firstXY() const;
+ Geom::Point firstXY() const;
/** Sets the first coordinates in the x and y vectors. */
- void setFirstXY(NR::Point &point);
+ void setFirstXY(Geom::Point &point);
private:
/// This holds the actual values.
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index 156ce0169..3cc26393b 100644
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -782,7 +782,7 @@ tweak_profile (double dist, double radius)
void
tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
- guint32 const rgb_goal, NR::Point p_w, double radius, double force, guint mode,
+ guint32 const rgb_goal, Geom::Point p_w, double radius, double force, guint mode,
bool do_h, bool do_s, bool do_l, bool /*do_o*/)
{
SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
@@ -790,8 +790,8 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
if (!gradient || !SP_IS_GRADIENT(gradient))
return;
- NR::Matrix i2d (sp_item_i2doc_affine (item));
- NR::Point p = p_w * i2d.inverse();
+ Geom::Matrix i2d (sp_item_i2doc_affine (item));
+ Geom::Point p = p_w * i2d.inverse();
p *= (gradient->gradientTransform).inverse();
// now p is in gradient's original coordinates
@@ -800,27 +800,27 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
if (SP_IS_LINEARGRADIENT(gradient)) {
SPLinearGradient *lg = SP_LINEARGRADIENT(gradient);
- NR::Point p1(lg->x1.computed, lg->y1.computed);
- NR::Point p2(lg->x2.computed, lg->y2.computed);
- NR::Point pdiff(p2 - p1);
- double vl = NR::L2(pdiff);
+ Geom::Point p1(lg->x1.computed, lg->y1.computed);
+ Geom::Point p2(lg->x2.computed, lg->y2.computed);
+ Geom::Point pdiff(p2 - p1);
+ double vl = Geom::L2(pdiff);
// This is the matrix which moves and rotates the gradient line
// so it's oriented along the X axis:
- NR::Matrix norm = NR::Matrix(Geom::Translate(-p1)) * NR::Matrix(Geom::Rotate(-atan2(pdiff[NR::Y], pdiff[NR::X])));
+ Geom::Matrix norm = Geom::Matrix(Geom::Translate(-p1)) * Geom::Matrix(Geom::Rotate(-atan2(pdiff[Geom::Y], pdiff[Geom::X])));
// Transform the mouse point by it to find out its projection onto the gradient line:
- NR::Point pnorm = p * norm;
+ Geom::Point pnorm = p * norm;
// Scale its X coordinate to match the length of the gradient line:
- pos = pnorm[NR::X] / vl;
+ pos = pnorm[Geom::X] / vl;
// Calculate radius in lenfth-of-gradient-line units
r = radius / vl;
} else if (SP_IS_RADIALGRADIENT(gradient)) {
SPRadialGradient *rg = SP_RADIALGRADIENT(gradient);
- NR::Point c (rg->cx.computed, rg->cy.computed);
- pos = NR::L2(p - c) / rg->r.computed;
+ Geom::Point c (rg->cx.computed, rg->cy.computed);
+ pos = Geom::L2(p - c) / rg->r.computed;
r = radius / rg->r.computed;
}
@@ -902,7 +902,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
guint32 stroke_goal, bool do_stroke,
float opacity_goal, bool do_opacity,
bool do_blur, bool reverse,
- NR::Point p, double radius, double force,
+ Geom::Point p, double radius, double force,
bool do_h, bool do_s, bool do_l, bool do_o)
{
bool did = false;
@@ -933,7 +933,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
Geom::Rect brush(p - Geom::Point(radius, radius), p + Geom::Point(radius, radius));
- NR::Point center = bbox->midpoint();
+ Geom::Point center = bbox->midpoint();
double this_force;
// if item == item_at_point, use max force
@@ -949,7 +949,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
// else if object > 0.5 brush: test 4 corners of bbox and center on being in the brush, choose max
// else if still smaller, then check only the object center:
} else {
- this_force = force * tweak_profile (NR::L2 (p - center), radius);
+ this_force = force * tweak_profile (Geom::L2 (p - center), radius);
}
if (this_force > 0.002) {
@@ -1033,7 +1033,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
bool
-sp_tweak_dilate (SPTweakContext *tc, NR::Point event_p, NR::Point p, NR::Point vector, bool reverse)
+sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::Point vector, bool reverse)
{
Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop);
SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop;
@@ -1123,7 +1123,7 @@ void
sp_tweak_update_area (SPTweakContext *tc)
{
double radius = get_dilate_radius(tc);
- NR::Matrix const sm (Geom::Scale(radius, radius) * Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point()));
+ Geom::Matrix const sm (Geom::Scale(radius, radius) * Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point()));
sp_canvas_item_affine_absolute(tc->dilate_area, sm);
sp_canvas_item_show(tc->dilate_area);
}
@@ -1174,9 +1174,9 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
return TRUE;
}
- NR::Point const button_w(event->button.x,
+ Geom::Point const button_w(event->button.x,
event->button.y);
- NR::Point const button_dt(desktop->w2d(button_w));
+ Geom::Point const button_dt(desktop->w2d(button_w));
tc->last_push = desktop->dt2doc(button_dt);
sp_tweak_extinput(tc, event);
@@ -1191,15 +1191,15 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
break;
case GDK_MOTION_NOTIFY:
{
- NR::Point const motion_w(event->motion.x,
+ Geom::Point const motion_w(event->motion.x,
event->motion.y);
- NR::Point motion_dt(desktop->w2d(motion_w));
- NR::Point motion_doc(desktop->dt2doc(motion_dt));
+ Geom::Point motion_dt(desktop->w2d(motion_w));
+ Geom::Point motion_doc(desktop->dt2doc(motion_dt));
sp_tweak_extinput(tc, event);
// draw the dilating cursor
double radius = get_dilate_radius(tc);
- NR::Matrix const sm (Geom::Scale(radius, radius) * Geom::Translate(desktop->w2d(motion_w)));
+ Geom::Matrix const sm (Geom::Scale(radius, radius) * Geom::Translate(desktop->w2d(motion_w)));
sp_canvas_item_affine_absolute(tc->dilate_area, sm);
sp_canvas_item_show(tc->dilate_area);
@@ -1227,8 +1227,8 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
case GDK_BUTTON_RELEASE:
{
- NR::Point const motion_w(event->button.x, event->button.y);
- NR::Point const motion_dt(desktop->w2d(motion_w));
+ Geom::Point const motion_w(event->button.x, event->button.y);
+ Geom::Point const motion_dt(desktop->w2d(motion_w));
sp_canvas_end_forced_full_redraws(desktop->canvas);
tc->is_drawing = false;
@@ -1237,7 +1237,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
if (!tc->has_dilated) {
// if we did not rub, do a light tap
tc->pressure = 0.03;
- sp_tweak_dilate (tc, motion_w, desktop->dt2doc(motion_dt), NR::Point(0,0), MOD__SHIFT);
+ sp_tweak_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT);
}
tc->is_dilating = false;
tc->has_dilated = false;
diff --git a/src/tweak-context.h b/src/tweak-context.h
index b5a9b6b7e..e860fd7ea 100644
--- a/src/tweak-context.h
+++ b/src/tweak-context.h
@@ -71,7 +71,7 @@ struct SPTweakContext
bool is_dilating;
bool has_dilated;
- NR::Point last_push;
+ Geom::Point last_push;
SPCanvasItem *dilate_area;
bool do_h;