summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f77fbba)
raw | patch | inline | side by side (parent: f77fbba)
author | Krzysztof Kosiński <tweenk.pl@gmail.com> | |
Tue, 6 Apr 2010 14:11:54 +0000 (16:11 +0200) | ||
committer | Krzysztof Kosiński <tweenk.pl@gmail.com> | |
Tue, 6 Apr 2010 14:11:54 +0000 (16:11 +0200) |
require an XML-level backwards compatibility mechanism to fix properly,
and it's too late in the 0.48 cycle to introduce it.
and it's too late in the 0.48 cycle to introduce it.
25 files changed:
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 6690e0af13eabbd6086241aebbb93474b7ce178c..52f1725779a2b0a00fd89c704b04bf6a8995920c 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
_active( false ),
_w2d(),
_d2w(),
- _doc2dt( Geom::identity() ),
+ _doc2dt( Geom::Scale(1, -1) ),
grids_visible( false )
{
_d2w.setIdentity();
@@ -272,6 +272,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
/* Connect event for page resize */
+ _doc2dt[5] = sp_document_height (document);
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
_modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
if (p[Geom::X] >= r0[Geom::X] &&
p[Geom::X] <= r1[Geom::X] &&
- p[Geom::Y] >= r0[Geom::Y] &&
- p[Geom::Y] <= r1[Geom::Y])
+ p[Geom::Y] >= r1[Geom::Y] &&
+ p[Geom::Y] <= r0[Geom::Y])
{
return p;
} else {
int clear = FALSE;
if (!NR_DF_TEST_CLOSE (newscale, scale, 1e-4 * scale)) {
// zoom changed - set new zoom factors
- _d2w = Geom::Scale(newscale);
- _w2d = Geom::Scale(1/newscale);
+ _d2w = Geom::Scale(newscale, -newscale);
+ _w2d = Geom::Scale(1/newscale, 1/-newscale);
sp_canvas_item_affine_absolute(SP_CANVAS_ITEM(main), _d2w);
clear = TRUE;
signal_zoom_changed.emit(_d2w.descrim());
@@ -801,10 +802,10 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double
/* Calculate top left corner (in document pixels) */
x0 = cx - 0.5 * viewbox.dimensions()[Geom::X] / newscale;
- y0 = cy - 0.5 * viewbox.dimensions()[Geom::Y] / newscale;
+ y1 = cy + 0.5 * viewbox.dimensions()[Geom::Y] / newscale;
/* Scroll */
- sp_canvas_scroll_to (canvas, x0 * newscale - border, y0 * newscale - border, clear);
+ sp_canvas_scroll_to (canvas, x0 * newscale - border, y1 * -newscale - border, clear);
/* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
sp_box3d_context_update_lines(event_context);
double const scale = _d2w[0];
- return viewbox * (1./scale);
+ 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));
}
/**
void
SPDesktop::onDocumentResized (gdouble width, gdouble height)
{
+ _doc2dt[5] = height;
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
Geom::Rect const a(Geom::Point(0, 0), Geom::Point(width, height));
SP_CTRLRECT(page)->setRectangle(a);
diff --git a/src/document.cpp b/src/document.cpp
index aeafaf1f95c637f52e26117046c497337ff8be61..101c54e30b687d38160ac0d9e2c55d4d0227e93a 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
document->base = NULL;
document->name = g_strdup(name);
- sp_object_repr_build_tree(document, rroot);
+ document->root = sp_object_repr_build_tree(document, rroot);
/* fixme: Not sure about this, but lets assume ::build updates */
rroot->setAttribute("inkscape:version", Inkscape::version_string);
double const w = rect.width();
double const h = rect.height();
+ double const old_height = sp_document_height(this);
SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX));
/* in px */
}
Geom::Rect const rect_with_margins(
- rect.min() - Geom::Point(margin_left, margin_top),
- rect.max() + Geom::Point(margin_right, margin_bottom));
+ rect.min() - Geom::Point(margin_left, margin_bottom),
+ rect.max() + Geom::Point(margin_right, margin_top));
sp_document_set_width(this, rect_with_margins.width(), &px);
sp_document_set_height(this, rect_with_margins.height(), &px);
- Geom::Translate const tr(-to_2geom(rect_with_margins.min()));
+ Geom::Translate const tr(
+ Geom::Point(0, old_height - rect_with_margins.height())
+ - to_2geom(rect_with_margins.min()));
SP_GROUP(root)->translateChildItems(tr);
if(nv) {
nv->translateGuides(tr2);
// update the viewport so the drawing appears to stay where it was
- nv->scrollAllDesktops(-tr2[0], -tr2[1], false);
+ nv->scrollAllDesktops(-tr2[0], tr2[1], false);
}
}
index 52f07059175ca4eb70df166cf4a567d28d868e4a..6e4bb3b7e366e8438c235ab21853627eb707c875 100644 (file)
@@ -631,8 +631,12 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
if (ret && !pageBoundingBox)
{
+ double high = sp_document_height(doc);
+ if (ctx->_vector_based_target)
+ high *= PT_PER_PX;
+
Geom::Matrix tp(Geom::Translate(-d.x0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
- -d.y0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ (d.y1 - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
ctx->transform(&tp);
}
index deef367a484753b69abd96a2a61cd174bb69c190..d4b35b261baec5cb49bb89bbdac225bb8bd07179 100644 (file)
namespace {
-void build_lines(int axis, Geom::Rect bounding_area, float offset,
- float spacing, SVG::PathString &path_data)
+Glib::ustring build_lines(int axis, Geom::Rect bounding_area,
+ float offset, float spacing)
{
Geom::Point point_offset(0.0, 0.0);
point_offset[axis] = offset;
+ SVG::PathString path_data;
for (Geom::Point start_point = bounding_area.min();
start_point[axis] + offset <= (bounding_area.max())[axis];
start_point[axis] += spacing) {
path_data.moveTo(start_point + point_offset)
.lineTo(end_point + point_offset);
}
+
+ return path_data;
}
}
if (bounds) {
bounding_area = *bounds;
}
- Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], bounding_area.min()[Geom::Y]),
- Geom::Point(bounding_area.max()[Geom::X], bounding_area.max()[Geom::Y]));
+
+ gdouble doc_height = sp_document_height(document->doc());
+ Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
+ Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
bounding_area = temprec;
}
@@ -98,9 +103,10 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
float offsets[2] = { module->get_param_float("xoffset"),
module->get_param_float("yoffset") };
- SVG::PathString path_data;
+ Glib::ustring path_data("");
for ( int axis = 0 ; axis < 2 ; ++axis ) {
- build_lines(axis, bounding_area, offsets[axis], spacings[axis], path_data);
+ path_data += build_lines(axis, bounding_area,
+ offsets[axis], spacings[axis]);
}
Inkscape::XML::Document * xml_doc = sp_document_repr_doc(document->doc());
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index 1fdf1d7fd04b5c0fb4bb2cb06002d573328d1935..28bba1bebcec4271a54e4cfa7e434525d024825d 100644 (file)
@@ -501,8 +501,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
if (!pageBoundingBox)
{
- Geom::Translate t(-d->min()[Geom::X], d->max()[Geom::Y] - sp_document_height(doc));
- push_transform( t );
+ push_transform( Geom::Translate( - d->min() ) );
}
// flip y-axis
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index 910b5dd808d367cd6883db829f18128064b31061..612ae1cfc6cbceef49f8b34e0b2b53d2d88cf6cb 100644 (file)
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -798,7 +798,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
unsigned int height = (int)ceil(screen.height() * zoom_scale * padding);
Geom::Point origin(screen.min()[Geom::X],
- screen.min()[Geom::Y]);
+ sp_document_height(document) - screen.height() - screen.min()[Geom::Y]);
origin[Geom::X] = origin[Geom::X] + (screen.width() * ((1 - padding) / 2));
origin[Geom::Y] = origin[Geom::Y] + (screen.height() * ((1 - padding) / 2));
@@ -905,7 +905,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
}
for (unsigned int i = 0; i < fill_points.size(); i++) {
- Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, (fill_points[i][Geom::Y] / zoom_scale)) * affine;
+ Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, sp_document_height(document) + (fill_points[i][Geom::Y] / zoom_scale)) * affine;
pw[Geom::X] = (int)MIN(width - 1, MAX(0, pw[Geom::X]));
pw[Geom::Y] = (int)MIN(height - 1, MAX(0, pw[Geom::Y]));
index c26d55b8b39c82372fea443172b2a109ad3c1947..3be63aa686abd54794b5531bb92652068126058f 100644 (file)
double padding = 1.0;
Geom::Point origin(screen.min()[Geom::X],
- screen.min()[Geom::Y]);
+ sp_document_height(doc) - screen[Geom::Y].extent() - screen.min()[Geom::Y]);
origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2));
origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2));
index 8eb9e27bfa027779d4a684dbb75da0fb4ca6f248..b1c135db02a2e5c3e2e63b910c79a9a32872c48e 100644 (file)
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
sp_document_ensure_up_to_date(doc);
- /* Calculate translation */
- Geom::Point translation = Geom::Point(-area[Geom::X][0], -area[Geom::Y][0]);
-
+ /* Calculate translation by transforming to document coordinates (flipping Y)*/
+ Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - sp_document_height(doc));
+
+ /* This calculation is only valid when assumed that (x0,y0)= area.corner(0) and (x1,y1) = area.corner(2)
+ * 1) a[0] * x0 + a[2] * y1 + a[4] = 0.0
+ * 2) a[1] * x0 + a[3] * y1 + a[5] = 0.0
+ * 3) a[0] * x1 + a[2] * y1 + a[4] = width
+ * 4) a[1] * x0 + a[3] * y0 + a[5] = height
+ * 5) a[1] = 0.0;
+ * 6) a[2] = 0.0;
+ *
+ * (1,3) a[0] * x1 - a[0] * x0 = width
+ * a[0] = width / (x1 - x0)
+ * (2,4) a[3] * y0 - a[3] * y1 = height
+ * a[3] = height / (y0 - y1)
+ * (1) a[4] = -a[0] * x0
+ * (2) a[5] = -a[3] * y1
+ */
Geom::Matrix const affine(Geom::Translate(translation)
* Geom::Scale(width / area.width(),
index 6fcb262475a674e30b1536ed21752070a9cdf184..2d0d5eb029f65b9ca1b1e1fc84031c0e277023a1 100644 (file)
@@ -135,16 +135,21 @@ KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape:
/* TODO: this pattern manipulation is not able to handle general transformation matrices. Only matrices that are the result of a pure scale times a pure rotation. */
-Geom::Point
-PatternKnotHolderEntityXY::knot_get()
+static gdouble sp_pattern_extract_theta(SPPattern *pat)
{
- SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+ Geom::Matrix transf = pat->patternTransform;
+ return Geom::atan2(transf.xAxis());
+}
- gdouble x = 0;
- gdouble y = -pattern_height(pat);
+static Geom::Point sp_pattern_extract_scale(SPPattern *pat)
+{
+ Geom::Matrix transf = pat->patternTransform;
+ return Geom::Point( transf.expansionX(), transf.expansionY() );
+}
- Geom::Point delta = Geom::Point(x,y) * pat->patternTransform;
- return delta;
+static Geom::Point sp_pattern_extract_trans(SPPattern const *pat)
+{
+ return Geom::Point(pat->patternTransform[4], pat->patternTransform[5]);
}
void
@@ -164,23 +169,32 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori
}
if (state) {
- Geom::Point knot_relpos(0, -pattern_height(pat));
- Geom::Point const q = p_snapped - (knot_relpos * pat->patternTransform);
+ Geom::Point const q = p_snapped - sp_pattern_extract_trans(pat);
sp_item_adjust_pattern(item, Geom::Matrix(Geom::Translate(q)));
}
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
+Geom::Point
+PatternKnotHolderEntityXY::knot_get()
+{
+ SPPattern const *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+ return sp_pattern_extract_trans(pat);
+}
+
Geom::Point
PatternKnotHolderEntityAngle::knot_get()
{
SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
- gdouble x = pattern_width(pat);
- gdouble y = -pattern_height(pat);
-
- Geom::Point delta = Geom::Point(x,y) * pat->patternTransform;
+ gdouble x = (pattern_width(pat));
+ gdouble y = 0;
+ Geom::Point delta = Geom::Point(x,y);
+ Geom::Point scale = sp_pattern_extract_scale(pat);
+ gdouble theta = sp_pattern_extract_theta(pat);
+ delta = delta * Geom::Matrix(Geom::Scale(scale))*Geom::Matrix(Geom::Rotate(theta));
+ delta = delta + sp_pattern_extract_trans(pat);
return delta;
}
@@ -192,38 +206,24 @@ PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const &
SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
- // rotate pattern around XY knot position
- Geom::Point knot_relpos(pattern_width(pat), -pattern_height(pat));
- Geom::Point xy_knot_relpos(0, -pattern_height(pat));
- Geom::Point transform_origin = xy_knot_relpos * pat->patternTransform;
-
- Geom::Point oldp = (knot_relpos * pat->patternTransform) - transform_origin;
- Geom::Point newp = p - transform_origin;
-
- gdouble theta = Geom::angle_between(oldp, newp);
+ // get the angle from pattern 0,0 to the cursor pos
+ Geom::Point delta = p - sp_pattern_extract_trans(pat);
+ gdouble theta = atan2(delta);
if ( state & GDK_CONTROL_MASK ) {
theta = sp_round(theta, M_PI/snaps);
}
- Geom::Matrix rot = Geom::Matrix(Geom::Translate(-transform_origin))
- * Geom::Rotate(theta)
- * Geom::Translate(transform_origin);
- sp_item_adjust_pattern(item, rot);
+ // get the scale from the current transform so we can keep it.
+ Geom::Point scl = sp_pattern_extract_scale(pat);
+ Geom::Matrix rot = Geom::Matrix(Geom::Scale(scl)) * Geom::Matrix(Geom::Rotate(theta));
+ Geom::Point const t = sp_pattern_extract_trans(pat);
+ rot[4] = t[Geom::X];
+ rot[5] = t[Geom::Y];
+ sp_item_adjust_pattern(item, rot, true);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
-Geom::Point
-PatternKnotHolderEntityScale::knot_get()
-{
- SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
-
- gdouble x = pattern_width(pat);
- gdouble y = 0;
- Geom::Point delta = Geom::Point(x,y) * pat->patternTransform;
- return delta;
-}
-
void
PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
@@ -232,32 +232,49 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &
// FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used.
Geom::Point p_snapped = snap_knot_position(p);
- Geom::Point knot_relpos(pattern_width(pat), 0);
- Geom::Point xy_knot_relpos(0, -pattern_height(pat));
- Geom::Point transform_origin = xy_knot_relpos * pat->patternTransform;
-
- // do the scaling in pattern coordinate space
- Geom::Point oldp = knot_relpos - xy_knot_relpos;
- Geom::Point newp = p_snapped * pat->patternTransform.inverse() - xy_knot_relpos;
-
- if (Geom::are_near(newp.length(), 0)) return;
+ // get angle from current transform
+ gdouble theta = sp_pattern_extract_theta(pat);
- Geom::Scale s(1);
- if (state & GDK_CONTROL_MASK) {
- // uniform scaling
- s = Geom::Scale(oldp * (newp.length() * oldp.length()));
+ // Get the new scale from the position of the knotholder
+ Geom::Point d = p_snapped - sp_pattern_extract_trans(pat);
+ gdouble pat_x = pattern_width(pat);
+ gdouble pat_y = pattern_height(pat);
+ Geom::Scale scl(1);
+ if ( state & GDK_CONTROL_MASK ) {
+ // if ctrl is pressed: use 1:1 scaling
+ gdouble pat_h = hypot(pat_x, pat_y);
+ scl = Geom::Scale(d.length() / pat_h);
} else {
- s = Geom::Scale(newp[Geom::X] / oldp[Geom::X], newp[Geom::Y] / oldp[Geom::Y]);
+ d *= Geom::Rotate(-theta);
+ scl = Geom::Scale(d[Geom::X] / pat_x, d[Geom::Y] / pat_y);
}
- Geom::Matrix scl = Geom::Matrix(Geom::Translate(-xy_knot_relpos))
- * s
- * Geom::Translate(xy_knot_relpos)
- * pat->patternTransform;
- sp_item_adjust_pattern(item, scl, true);
+ Geom::Matrix rot = (Geom::Matrix)scl * Geom::Rotate(theta);
+
+ Geom::Point const t = sp_pattern_extract_trans(pat);
+ rot[4] = t[Geom::X];
+ rot[5] = t[Geom::Y];
+ sp_item_adjust_pattern(item, rot, true);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
+
+Geom::Point
+PatternKnotHolderEntityScale::knot_get()
+{
+ SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+
+ gdouble x = pattern_width(pat);
+ gdouble y = pattern_height(pat);
+ Geom::Point delta = Geom::Point(x,y);
+ Geom::Matrix a = pat->patternTransform;
+ a[4] = 0;
+ a[5] = 0;
+ delta = delta * a;
+ delta = delta + sp_pattern_extract_trans(pat);
+ return delta;
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/select-context.cpp b/src/select-context.cpp
index 9035021d691d16270d819cee61c7f2ebf858ff66..028c8634b62435475a926670ec97082a881c66f7 100644 (file)
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
@@ -765,12 +765,12 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
gint mul = 1 + gobble_key_events(
get_group0_keyval(&event->key), 0); // with any mask
if (MOD__ALT) { // alt
- if (MOD__SHIFT) sp_selection_move_screen(desktop, 0, mul*-10); // shift
- else sp_selection_move_screen(desktop, 0, mul*-1); // no shift
+ if (MOD__SHIFT) sp_selection_move_screen(desktop, 0, mul*10); // shift
+ else sp_selection_move_screen(desktop, 0, mul*1); // no shift
}
else { // no alt
- if (MOD__SHIFT) sp_selection_move(desktop, 0, mul*-10*nudge); // shift
- else sp_selection_move(desktop, 0, mul*-nudge); // no shift
+ if (MOD__SHIFT) sp_selection_move(desktop, 0, mul*10*nudge); // shift
+ else sp_selection_move(desktop, 0, mul*nudge); // no shift
}
ret = TRUE;
}
@@ -799,12 +799,12 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
gint mul = 1 + gobble_key_events(
get_group0_keyval(&event->key), 0); // with any mask
if (MOD__ALT) { // alt
- if (MOD__SHIFT) sp_selection_move_screen(desktop, 0, mul*10); // shift
- else sp_selection_move_screen(desktop, 0, mul*1); // no shift
+ if (MOD__SHIFT) sp_selection_move_screen(desktop, 0, mul*-10); // shift
+ else sp_selection_move_screen(desktop, 0, mul*-1); // no shift
}
else { // no alt
- if (MOD__SHIFT) sp_selection_move(desktop, 0, mul*10*nudge); // shift
- else sp_selection_move(desktop, 0, mul*nudge); // no shift
+ if (MOD__SHIFT) sp_selection_move(desktop, 0, mul*-10*nudge); // shift
+ else sp_selection_move(desktop, 0, mul*-nudge); // no shift
}
ret = TRUE;
}
get_group0_keyval(&event->key), 0); // with any mask
sp_selection_rotate_screen(selection, mul*1);
} else if (MOD__CTRL) {
- sp_selection_rotate(selection, -90);
+ sp_selection_rotate(selection, 90);
} else if (snaps) {
- sp_selection_rotate(selection, -180/snaps);
+ sp_selection_rotate(selection, 180/snaps);
}
ret = TRUE;
break;
get_group0_keyval(&event->key), 0); // with any mask
sp_selection_rotate_screen(selection, -1*mul);
} else if (MOD__CTRL) {
- sp_selection_rotate(selection, 90);
+ sp_selection_rotate(selection, -90);
} else if (snaps) {
- sp_selection_rotate(selection, 180/snaps);
+ sp_selection_rotate(selection, -180/snaps);
}
ret = TRUE;
break;
index 452a4ff9d7ab762a379c685f39df399a259aefc7..730467ee548bd90479e73f974addfe32c101eb49 100644 (file)
}
// calculate the transform to be applied to objects to move them to 0,0
- Geom::Point move_p = -*c;
- Geom::Matrix move = Geom::Translate(move_p);
+ Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - *c;
+ move_p[Geom::Y] = -move_p[Geom::Y];
+ Geom::Matrix move = Geom::Matrix(Geom::Translate(move_p));
GSList *items = g_slist_copy((GSList *) selection->itemList());
}
// calculate the transform to be applied to objects to move them to 0,0
- Geom::Point move_p = -(r->min() + Geom::Point(0, r->dimensions()[Geom::Y]));
+ Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y]));
+ move_p[Geom::Y] = -move_p[Geom::Y];
Geom::Matrix move = Geom::Matrix(Geom::Translate(move_p));
GSList *items = g_slist_copy((GSList *) selection->itemList());
Geom::Matrix t;
double shift_x = bbox.x0;
- double shift_y = bbox.y0;
+ double shift_y = bbox.y1;
if (res == PX_PER_IN) { // for default 90 dpi, snap it to pixel grid
shift_x = round(shift_x);
- shift_y = round(shift_y);
+ shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone
}
- t = Geom::Translate(shift_x, shift_y) * eek.inverse();
+ t = Geom::Scale(1, -1) * Geom::Translate(shift_x, shift_y) * eek.inverse();
// Do the export
sp_export_png_file(document, filepath,
index ba18b2a5bd70f0953fdab393eb6299dc0fb3ec2e..95b680c5e5fc81fbb5e7675f7cf46e39bba56896 100644 (file)
--- a/src/seltrans-handles.cpp
+++ b/src/seltrans-handles.cpp
SPSelTransHandle const handles_scale[] = {
//anchor cursor control action request x y
- {GTK_ANCHOR_NE, GDK_TOP_LEFT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 1},
- {GTK_ANCHOR_N, GDK_TOP_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 1},
- {GTK_ANCHOR_NW, GDK_TOP_RIGHT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 1},
+ {GTK_ANCHOR_SE, GDK_TOP_LEFT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 1},
+ {GTK_ANCHOR_S, GDK_TOP_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 1},
+ {GTK_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 1},
{GTK_ANCHOR_W, GDK_RIGHT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 1, 0.5},
- {GTK_ANCHOR_SW, GDK_BOTTOM_RIGHT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 0},
- {GTK_ANCHOR_S, GDK_BOTTOM_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 0},
- {GTK_ANCHOR_SE, GDK_BOTTOM_LEFT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 0},
+ {GTK_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 0},
+ {GTK_ANCHOR_N, GDK_BOTTOM_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 0},
+ {GTK_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 0},
{GTK_ANCHOR_E, GDK_LEFT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0, 0.5}
};
SPSelTransHandle const handles_rotate[] = {
- {GTK_ANCHOR_NE, GDK_EXCHANGE, 10, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 1},
- {GTK_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 5, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 1},
- {GTK_ANCHOR_NW, GDK_EXCHANGE, 8, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 1},
+ {GTK_ANCHOR_SE, GDK_EXCHANGE, 4, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 1},
+ {GTK_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 5, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 1},
+ {GTK_ANCHOR_SW, GDK_EXCHANGE, 6, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 1},
{GTK_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 7, sp_sel_trans_skew, sp_sel_trans_skew_request, 1, 0.5},
- {GTK_ANCHOR_SW, GDK_EXCHANGE, 6, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 0},
- {GTK_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 9, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 0},
- {GTK_ANCHOR_SE, GDK_EXCHANGE, 4, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 0},
+ {GTK_ANCHOR_NW, GDK_EXCHANGE, 8, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 0},
+ {GTK_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 9, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 0},
+ {GTK_ANCHOR_NE, GDK_EXCHANGE, 10, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 0},
{GTK_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, sp_sel_trans_skew, sp_sel_trans_skew_request, 0, 0.5}
};
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index def0399373126139b20ec18cb58bf5295f6edab8..f5edf7d97cf3a63baf9820d97bf57822ae640f1b 100644 (file)
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -217,14 +217,12 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
success += sp_svg_number_read_d(strarray[1], &newy);
g_strfreev (strarray);
if (success == 2) {
- // Desktop coords fix
- guide->point_on_line = Geom::Point(newx, sp_document_height(guide->document) - newy);
+ guide->point_on_line = Geom::Point(newx, newy);
} else if (success == 1) {
// before 0.46 style guideline definition.
const gchar *attr = SP_OBJECT_REPR(object)->attribute("orientation");
if (attr && !strcmp(attr, "horizontal")) {
- // Desktop coords fix
- guide->point_on_line = Geom::Point(0, sp_document_height(guide->document) - newx);
+ guide->point_on_line = Geom::Point(0, newx);
} else {
guide->point_on_line = Geom::Point(newx, 0);
}
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index f60a2b27a6de18e9a93feb4fe3ae77551488e63b..c4411e47d2ed100f83b3a5290e0d62b51320a2f3 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
g_assert(SP_IS_ITEM(item));
Geom::Matrix const ret( sp_item_i2doc_affine(item)
- );
+ * Geom::Scale(1, -1)
+ * Geom::Translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item))) );
return ret;
}
if (SP_OBJECT_PARENT(item)) {
dt2p = sp_item_i2d_affine((SPItem *) SP_OBJECT_PARENT(item)).inverse();
} else {
- dt2p = ( Geom::identity() );
+ dt2p = ( Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item)))
+ * Geom::Scale(1, -1) );
}
Geom::Matrix const i2p( i2dt * dt2p );
diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp
index e32819746f52cdb54dee18d6a1d6a0884151e8ff..62143e3ab047d458d07f611047ff00cf4935a75b 100644 (file)
--- a/src/sp-object-repr.cpp
+++ b/src/sp-object-repr.cpp
static GType name_to_gtype(NameType name_type, gchar const *name);
/**
- * Construct an SPRoot and all its descendents from the given XML representation.
+ * Construct an SPRoot and all its descendents from the given repr.
*/
-void
+SPObject *
sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr)
{
g_assert(document != NULL);
g_assert(name != NULL);
GType const type = name_to_gtype(REPR_NAME, name);
g_assert(g_type_is_a(type, SP_TYPE_ROOT));
+ gpointer newobj = g_object_new(type, 0);
+ g_assert(newobj != NULL);
+ SPObject *const object = SP_OBJECT(newobj);
+ g_assert(object != NULL);
+ sp_object_invoke_build(object, document, repr, FALSE);
- // create and assign root
- SPObject *root = SP_OBJECT(g_object_new(type, 0));
- g_assert(root != NULL);
- document->root = root;
-
- // recursively create SP tree elements
- sp_object_invoke_build(root, document, repr, FALSE);
+ return object;
}
GType
diff --git a/src/sp-object-repr.h b/src/sp-object-repr.h
index 43aead41e886be8f9f1d9406f6cbcbf76e1f69a0..f3a80f83c77a1259279d1f3b99dfd85b08a3828c 100644 (file)
--- a/src/sp-object-repr.h
+++ b/src/sp-object-repr.h
}
-void sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr);
+SPObject *sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr);
GType sp_repr_type_lookup (Inkscape::XML::Node *repr);
diff --git a/src/spray-context.cpp b/src/spray-context.cpp
index 9b9caee150418b3e8a7725a582e8885ae57f9138..2bdac197f75e749d18a7ab9541e4940deccb9f16 100644 (file)
--- a/src/spray-context.cpp
+++ b/src/spray-context.cpp
sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
//Move the cursor p
Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
- sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], move[Geom::Y]));
+ sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
did = true;
}
}
sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale));
sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale));
sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
- sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], move[Geom::Y]));
+ sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
// union and duplication
selection->clear();
sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale));
sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
- sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], move[Geom::Y]));
+ sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
Inkscape::GC::release(clone);
diff --git a/src/text-context.cpp b/src/text-context.cpp
index 984876f783b1f5de32ccf2844f5322b25ed732ec..4f89bd1e144bd5cf106425fa275a5f7d25e3b703 100644 (file)
--- a/src/text-context.cpp
+++ b/src/text-context.cpp
@@ -684,7 +684,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
// Cursor height is defined by the new text object's font size; it needs to be set
// articifically here, for the text object does not exist yet:
double cursor_height = sp_desktop_get_font_size_tool(desktop);
- sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), dtp, dtp - Geom::Point(0, cursor_height));
+ sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), dtp, dtp + Geom::Point(0, cursor_height));
event_context->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Type text; <b>Enter</b> to start new line.")); // FIXME:: this is a copy of a string from _update_cursor below, do not desync
event_context->within_tolerance = false;
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index a34a61f53cc05292f381283338a49b3a2585d584..13299b5a4004fef123cb90f05cc659879cd7ca24 100644 (file)
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -448,7 +448,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (a->contains(p)) x = 0;
if (x < 1) {
Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) * vector;
- sp_item_move_rel(item, Geom::Translate(move[Geom::X], move[Geom::Y]));
+ sp_item_move_rel(item, Geom::Translate(move[Geom::X], -move[Geom::Y]));
did = true;
}
}
@@ -462,7 +462,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (x < 1) {
Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) *
(reverse? (a->midpoint() - p) : (p - a->midpoint()));
- sp_item_move_rel(item, Geom::Translate(move[Geom::X], move[Geom::Y]));
+ sp_item_move_rel(item, Geom::Translate(move[Geom::X], -move[Geom::Y]));
did = true;
}
}
@@ -477,7 +477,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (a->contains(p)) x = 0;
if (x < 1) {
Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) * Geom::Point(cos(dp)*dr, sin(dp)*dr);
- sp_item_move_rel(item, Geom::Translate(move[Geom::X], move[Geom::Y]));
+ sp_item_move_rel(item, Geom::Translate(move[Geom::X], -move[Geom::Y]));
did = true;
}
}
@@ -502,7 +502,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
double x = Geom::L2(a->midpoint() - p)/radius;
if (a->contains(p)) x = 0;
if (x < 1) {
- double angle = (reverse? -force : force) * 0.05 * (cos(M_PI * x) + 1) * M_PI;
+ double angle = (reverse? force : -force) * 0.05 * (cos(M_PI * x) + 1) * M_PI;
sp_item_rotate_rel(item, Geom::Rotate(angle));
did = true;
}
index f27c49f61e81b9ac02317d04d40afc886403c730..a75a8d68d9eea638e162784d9407391aa94b4ae2 100644 (file)
{.5, .5, 0., 0., .5, .5, 0., 0.},
{0., 1., 0., 0., 0., 1., 0., 0.},
{0., 1., 0., 0., 1., 0., 0., 0.},
- {0., 0., 1., 0., 0., 0., 0., 1.},
- {0., 0., 1., 0., 0., 0., 1., 0.},
- {0., 0., .5, .5, 0., 0., .5, .5},
+ {0., 0., 0., 1., 0., 0., 1., 0.},
{0., 0., 0., 1., 0., 0., 0., 1.},
- {0., 0., 0., 1., 0., 0., 1., 0.}
+ {0., 0., .5, .5, 0., 0., .5, .5},
+ {0., 0., 1., 0., 0., 0., 1., 0.},
+ {0., 0., 1., 0., 0., 0., 0., 1.}
};
BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd) :
addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_TOP,
_("Distribute top edges equidistantly"),
- 1, 1, false, Geom::Y, 1., 0.);
+ 1, 1, false, Geom::Y, 0, 1);
addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_CENTER,
_("Distribute centers equidistantly vertically"),
1, 2, false, Geom::Y, .5, .5);
addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BOTTOM,
_("Distribute bottom edges equidistantly"),
- 1, 3, false, Geom::Y, 0., 1.);
+ 1, 3, false, Geom::Y, 1., 0.);
//Baseline distribs
addBaselineButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_BASELINE,
index c7fc8a3cc041058dbadf1a28d6875c2010cf8c5d..f880d2ddfe2c9faf604f3add7c9588b7d1257951 100644 (file)
case GDK_Up:
case GDK_KP_Up:
case GDK_KP_8:
- return _keyboardMove(event->key, Geom::Point(0, -1));
+ return _keyboardMove(event->key, Geom::Point(0, 1));
case GDK_Down:
case GDK_KP_Down:
case GDK_KP_2:
- return _keyboardMove(event->key, Geom::Point(0, 1));
+ return _keyboardMove(event->key, Geom::Point(0, -1));
case GDK_Right:
case GDK_KP_Right:
case GDK_KP_6:
// rotates
case GDK_bracketleft:
- return _keyboardRotate(event->key, -1);
- case GDK_bracketright:
return _keyboardRotate(event->key, 1);
+ case GDK_bracketright:
+ return _keyboardRotate(event->key, -1);
// scaling
case GDK_less:
index 392518207a94ea7ac305ebe9b3e56f2f8cadbced..2025a12d7b4826cc54f7de1d9306792eec78dabc 100644 (file)
// single handle functions
// rotation
case GDK_bracketleft:
- pm.rotateHandle(n, which, -1, one_pixel);
+ case GDK_braceleft:
+ pm.rotateHandle(n, which, 1, one_pixel);
break;
case GDK_bracketright:
- pm.rotateHandle(n, which, 1, one_pixel);
+ case GDK_braceright:
+ pm.rotateHandle(n, which, -1, one_pixel);
break;
// adjust length
case GDK_period:
index a50be873a94d57cd3bcbe09b1c4ea407529156da..66f72f379ee985706ba107d7d4492da579804cee 100644 (file)
Geom::Point at = j->pointAt(0.5);
Geom::Point ut = j->unitTangentAt(0.5);
// rotate the point
- ut *= Geom::Rotate(210.0 / 180.0 * M_PI);
+ ut *= Geom::Rotate(150.0 / 180.0 * M_PI);
Geom::Point arrow_end = _desktop->w2d(
_desktop->d2w(at) + Geom::unit_vector(_desktop->d2w(ut)) * 10.0);
index 4cbc5ed4d4e91b062d1975d1ebbe3340ae4a2404..1af848b964d0a0930d6088df5365ef150dfcc55b 100644 (file)
namespace {
Gtk::AnchorType corner_to_anchor(unsigned c) {
switch (c % 4) {
- case 0: return Gtk::ANCHOR_SE;
- case 1: return Gtk::ANCHOR_SW;
- case 2: return Gtk::ANCHOR_NW;
- default: return Gtk::ANCHOR_NE;
+ case 0: return Gtk::ANCHOR_NE;
+ case 1: return Gtk::ANCHOR_NW;
+ case 2: return Gtk::ANCHOR_SW;
+ default: return Gtk::ANCHOR_SE;
}
}
Gtk::AnchorType side_to_anchor(unsigned s) {
switch (s % 4) {
- case 0: return Gtk::ANCHOR_S;
+ case 0: return Gtk::ANCHOR_N;
case 1: return Gtk::ANCHOR_W;
- case 2: return Gtk::ANCHOR_N;
+ case 2: return Gtk::ANCHOR_S;
default: return Gtk::ANCHOR_E;
}
}
static Glib::RefPtr<Gdk::Pixbuf> _corner_to_pixbuf(unsigned c) {
sp_select_context_get_type();
switch (c % 2) {
- case 0: return Glib::wrap(handles[0], true);
- default: return Glib::wrap(handles[1], true);
+ case 0: return Glib::wrap(handles[1], true);
+ default: return Glib::wrap(handles[0], true);
}
}
Geom::Point _sc_center;
static Glib::RefPtr<Gdk::Pixbuf> _corner_to_pixbuf(unsigned c) {
sp_select_context_get_type();
switch (c % 4) {
- case 0: return Glib::wrap(handles[4], true);
- case 1: return Glib::wrap(handles[6], true);
- case 2: return Glib::wrap(handles[8], true);
- default: return Glib::wrap(handles[10], true);
+ case 0: return Glib::wrap(handles[10], true);
+ case 1: return Glib::wrap(handles[8], true);
+ case 2: return Glib::wrap(handles[6], true);
+ default: return Glib::wrap(handles[4], true);
}
}
Geom::Point _rot_center;
index 48317aa3e027122c871b09caebb897da90a8526a..ab440595f24e0e6a06c12e934cb8aa2e3698c4fa 100644 (file)
NR::IRect viewbox = dtw->canvas->getViewboxIntegers();
double const scale = dtw->desktop->current_zoom();
- double s = viewbox.min()[Geom::Y] / scale - dtw->ruler_origin[Geom::Y];
- double e = viewbox.max()[Geom::Y] / scale - dtw->ruler_origin[Geom::Y];
+ double s = viewbox.min()[Geom::Y] / -scale - dtw->ruler_origin[Geom::Y];
+ double e = viewbox.max()[Geom::Y] / -scale - dtw->ruler_origin[Geom::Y];
gtk_ruler_set_range(GTK_RULER(dtw->vruler), s, e, GTK_RULER(dtw->vruler)->position, (e - s));
}
Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item));
/* Canvas region we always show unconditionally */
- Geom::Rect carea( Geom::Point(deskarea->left() * scale - 64, deskarea->top() * scale - 64),
- Geom::Point(deskarea->right() * scale + 64, deskarea->bottom() * scale + 64) );
+ Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64),
+ Geom::Point(deskarea->max()[Geom::X] * scale + 64, deskarea->min()[Geom::Y] * -scale + 64) );
Geom::Rect viewbox = dtw->canvas->getViewbox();