From: Krzysztof KosiƄski Date: Sat, 3 Apr 2010 01:56:36 +0000 (+0200) Subject: Initial fix for the inverted coordinate system bug X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2f14c415cc9f837009bac99cb36d80404120f5a9;p=inkscape.git Initial fix for the inverted coordinate system bug --- diff --git a/src/desktop.cpp b/src/desktop.cpp index 52f172577..c45cf8004 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -158,7 +158,7 @@ SPDesktop::SPDesktop() : _active( false ), _w2d(), _d2w(), - _doc2dt( Geom::Scale(1, -1) ), + _doc2dt( Geom::identity() ), grids_visible( false ) { _d2w.setIdentity(); @@ -272,7 +272,6 @@ 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)); @@ -793,8 +792,8 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double int clear = FALSE; if (!NR_DF_TEST_CLOSE (newscale, scale, 1e-4 * scale)) { // zoom changed - set new zoom factors - _d2w = Geom::Scale(newscale, -newscale); - _w2d = Geom::Scale(1/newscale, 1/-newscale); + _d2w = Geom::Scale(newscale); + _w2d = Geom::Scale(1/newscale); sp_canvas_item_affine_absolute(SP_CANVAS_ITEM(main), _d2w); clear = TRUE; signal_zoom_changed.emit(_d2w.descrim()); @@ -802,10 +801,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; - y1 = cy + 0.5 * viewbox.dimensions()[Geom::Y] / newscale; + y0 = cy - 0.5 * viewbox.dimensions()[Geom::Y] / newscale; /* Scroll */ - sp_canvas_scroll_to (canvas, x0 * newscale - border, y1 * -newscale - border, clear); + sp_canvas_scroll_to (canvas, x0 * newscale - border, y0 * 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); @@ -829,8 +828,7 @@ Geom::Rect SPDesktop::get_display_area() const double const scale = _d2w[0]; - 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)); + return viewbox * (1./scale); } /** diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index b1c135db0..8eb9e27bf 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -424,24 +424,9 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, sp_document_ensure_up_to_date(doc); - /* 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 - */ + /* Calculate translation */ + Geom::Point translation = Geom::Point(-area[Geom::X][0], -area[Geom::Y][0]); + Geom::Matrix const affine(Geom::Translate(translation) * Geom::Scale(width / area.width(), diff --git a/src/select-context.cpp b/src/select-context.cpp index 028c8634b..8500e9084 100644 --- 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; } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 730467ee5..7ac2e5471 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2748,12 +2748,12 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) Geom::Matrix t; double shift_x = bbox.x0; - double shift_y = bbox.y1; + double shift_y = bbox.y0; if (res == PX_PER_IN) { // for default 90 dpi, snap it to pixel grid shift_x = round(shift_x); - shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone + shift_y = round(shift_y); } - t = Geom::Scale(1, -1) * Geom::Translate(shift_x, shift_y) * eek.inverse(); + t = Geom::Translate(shift_x, shift_y) * eek.inverse(); // Do the export sp_export_png_file(document, filepath, diff --git a/src/seltrans-handles.cpp b/src/seltrans-handles.cpp index 95b680c5e..ba18b2a5b 100644 --- a/src/seltrans-handles.cpp +++ b/src/seltrans-handles.cpp @@ -5,24 +5,24 @@ SPSelTransHandle const handles_scale[] = { //anchor cursor control action request x y - {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_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_W, GDK_RIGHT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 1, 0.5}, - {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_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_E, GDK_LEFT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0, 0.5} }; SPSelTransHandle const handles_rotate[] = { - {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_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_W, GDK_SB_V_DOUBLE_ARROW, 7, sp_sel_trans_skew, sp_sel_trans_skew_request, 1, 0.5}, - {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_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_E, GDK_SB_V_DOUBLE_ARROW, 11, sp_sel_trans_skew, sp_sel_trans_skew_request, 0, 0.5} }; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index c4411e47d..f60a2b27a 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1574,8 +1574,7 @@ Geom::Matrix sp_item_i2d_affine(SPItem const *item) 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; } @@ -1588,8 +1587,7 @@ void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt) if (SP_OBJECT_PARENT(item)) { dt2p = sp_item_i2d_affine((SPItem *) SP_OBJECT_PARENT(item)).inverse(); } else { - dt2p = ( Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item))) - * Geom::Scale(1, -1) ); + dt2p = ( Geom::identity() ); } Geom::Matrix const i2p( i2dt * dt2p ); diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index f880d2ddf..dfbf1170a 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -545,11 +545,11 @@ bool ControlPointSelection::event(GdkEvent *event) 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: diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 66f72f379..a50be873a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1193,7 +1193,7 @@ void PathManipulator::_updateOutline() Geom::Point at = j->pointAt(0.5); Geom::Point ut = j->unitTangentAt(0.5); // rotate the point - ut *= Geom::Rotate(150.0 / 180.0 * M_PI); + ut *= Geom::Rotate(210.0 / 180.0 * M_PI); Geom::Point arrow_end = _desktop->w2d( _desktop->d2w(at) + Geom::unit_vector(_desktop->d2w(ut)) * 10.0); diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 1af848b96..4cbc5ed4d 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -34,17 +34,17 @@ namespace UI { namespace { Gtk::AnchorType corner_to_anchor(unsigned c) { switch (c % 4) { - case 0: return Gtk::ANCHOR_NE; - case 1: return Gtk::ANCHOR_NW; - case 2: return Gtk::ANCHOR_SW; - default: return Gtk::ANCHOR_SE; + case 0: return Gtk::ANCHOR_SE; + case 1: return Gtk::ANCHOR_SW; + case 2: return Gtk::ANCHOR_NW; + default: return Gtk::ANCHOR_NE; } } Gtk::AnchorType side_to_anchor(unsigned s) { switch (s % 4) { - case 0: return Gtk::ANCHOR_N; + case 0: return Gtk::ANCHOR_S; case 1: return Gtk::ANCHOR_W; - case 2: return Gtk::ANCHOR_S; + case 2: return Gtk::ANCHOR_N; default: return Gtk::ANCHOR_E; } } @@ -208,8 +208,8 @@ private: static Glib::RefPtr _corner_to_pixbuf(unsigned c) { sp_select_context_get_type(); switch (c % 2) { - case 0: return Glib::wrap(handles[1], true); - default: return Glib::wrap(handles[0], true); + case 0: return Glib::wrap(handles[0], true); + default: return Glib::wrap(handles[1], true); } } Geom::Point _sc_center; @@ -332,10 +332,10 @@ private: static Glib::RefPtr _corner_to_pixbuf(unsigned c) { sp_select_context_get_type(); switch (c % 4) { - 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); + 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); } } Geom::Point _rot_center; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index ab440595f..48317aa3e 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1493,8 +1493,8 @@ sp_desktop_widget_update_vruler (SPDesktopWidget *dtw) 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)); } @@ -1809,8 +1809,8 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item)); /* Canvas region we always show unconditionally */ - 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 carea( Geom::Point(deskarea->left() * scale - 64, deskarea->top() * scale - 64), + Geom::Point(deskarea->right() * scale + 64, deskarea->bottom() * scale + 64) ); Geom::Rect viewbox = dtw->canvas->getViewbox();