From: cilix42 Date: Thu, 18 Sep 2008 17:43:41 +0000 (+0000) Subject: More NR::Point ==> Geom::Point X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c4ae5c46c1d9c171f96e47e81f2f0f5f0e189547;p=inkscape.git More NR::Point ==> Geom::Point --- diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 0ea8b1dbd..03a9073b4 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -302,12 +302,12 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven switch (event->type) { case GDK_BUTTON_PRESS: if ( event->button.button == 1 && !event_context->space_panning) { - NR::Point const button_w(event->button.x, - event->button.y); + Geom::Point const button_w(event->button.x, + event->button.y); // save drag origin - event_context->xp = (gint) button_w[NR::X]; - event_context->yp = (gint) button_w[NR::Y]; + event_context->xp = (gint) button_w[Geom::X]; + event_context->yp = (gint) button_w[Geom::Y]; event_context->within_tolerance = true; // remember clicked item, *not* disregarding groups (since a 3D box is a group), honoring Alt @@ -357,9 +357,9 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven // motion notify coordinates as given (no snapping back to origin) event_context->within_tolerance = false; - NR::Point const motion_w(event->motion.x, - event->motion.y); - Geom::Point motion_dt(to_2geom(desktop->w2d(motion_w))); + Geom::Point const motion_w(event->motion.x, + event->motion.y); + Geom::Point motion_dt(desktop->w2d(motion_w)); SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, true, bc->item); diff --git a/src/box3d-context.h b/src/box3d-context.h index 3432a1a5b..8bafa75f2 100644 --- a/src/box3d-context.h +++ b/src/box3d-context.h @@ -31,7 +31,7 @@ class Box3DContextClass; struct Box3DContext : public SPEventContext { SPItem *item; - NR::Point center; + Geom::Point center; /** * save three corners while dragging: @@ -41,9 +41,9 @@ struct Box3DContext : public SPEventContext { * if we are ctrl-dragging but is constrained to the perspective line from drag_ptC * to the vanishing point Y otherwise) */ - NR::Point drag_origin; - NR::Point drag_ptB; - NR::Point drag_ptC; + Geom::Point drag_origin; + Geom::Point drag_ptB; + Geom::Point drag_ptC; Proj::Pt3 drag_origin_proj; Proj::Pt3 drag_ptB_proj; diff --git a/src/box3d.cpp b/src/box3d.cpp index a517ea0a2..6f4253cab 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -403,13 +403,13 @@ box3d_get_proj_corner (SPBox3D const *box, guint id) { 1.0); } -NR::Point +Geom::Point box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords) { Proj::Pt3 proj_corner (box3d_get_proj_corner (box, id)); if (!box3d_get_perspective(box)) { - return NR::Point (NR_HUGE, NR_HUGE); + return Geom::Point (NR_HUGE, NR_HUGE); } - NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); + Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); if (item_coords) { return box3d_get_perspective(box)->tmat.image(proj_corner).affine() * i2d.inverse(); } else { @@ -427,13 +427,13 @@ box3d_get_proj_center (SPBox3D *box) { 1.0); } -NR::Point +Geom::Point box3d_get_center_screen (SPBox3D *box) { Proj::Pt3 proj_center (box3d_get_proj_center (box)); if (!box3d_get_perspective(box)) { - return NR::Point (NR_HUGE, NR_HUGE); + return Geom::Point (NR_HUGE, NR_HUGE); } - NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); + Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); return box3d_get_perspective(box)->tmat.image(proj_center).affine() * i2d.inverse(); } @@ -461,12 +461,12 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta Proj::Pt3 E_proj (x_coord - diff_x, y_coord + diff_y, z_coord, 1.0); Persp3D *persp = box3d_get_perspective(box); - NR::Point A = persp->tmat.image(A_proj).affine(); - NR::Point B = persp->tmat.image(B_proj).affine(); - NR::Point C = persp->tmat.image(C_proj).affine(); - NR::Point D = persp->tmat.image(D_proj).affine(); - NR::Point E = persp->tmat.image(E_proj).affine(); - NR::Point pt = persp->tmat.image(pt_proj).affine(); + Geom::Point A = persp->tmat.image(A_proj).affine(); + Geom::Point B = persp->tmat.image(B_proj).affine(); + Geom::Point C = persp->tmat.image(C_proj).affine(); + Geom::Point D = persp->tmat.image(D_proj).affine(); + Geom::Point E = persp->tmat.image(E_proj).affine(); + Geom::Point pt = persp->tmat.image(pt_proj).affine(); // TODO: Replace these lines between corners with lines from a corner to a vanishing point // (this might help to prevent rounding errors if the box is small) @@ -476,7 +476,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta Box3D::Line diag2(A, E); // diag2 is only taken into account if id equals -1, i.e., if we are snapping the center int num_snap_lines = (id != -1) ? 3 : 4; - NR::Point snap_pts[num_snap_lines]; + Geom::Point snap_pts[num_snap_lines]; snap_pts[0] = pl1.closest_to (pt); snap_pts[1] = pl2.closest_to (pt); @@ -515,7 +515,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta // snap to the closest point (or the previously remembered one // if we are within tolerance of the starting point) - NR::Point result; + Geom::Point result; if (within_tolerance) { result = snap_pts[remember_snap_index]; } else { @@ -526,7 +526,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta } void -box3d_set_corner (SPBox3D *box, const guint id, NR::Point const &new_pos, const Box3D::Axis movement, bool constrained) { +box3d_set_corner (SPBox3D *box, const guint id, Geom::Point const &new_pos, const Box3D::Axis movement, bool constrained) { g_return_if_fail ((movement != Box3D::NONE) && (movement != Box3D::XYZ)); box->orig_corner0.normalize(); @@ -555,7 +555,7 @@ box3d_set_corner (SPBox3D *box, const guint id, NR::Point const &new_pos, const Box3D::PerspectiveLine pl(persp->tmat.image( box3d_get_proj_corner (id, box->save_corner0, box->save_corner7)).affine(), Proj::Z, persp); - NR::Point new_pos_snapped(pl.closest_to(new_pos)); + Geom::Point new_pos_snapped(pl.closest_to(new_pos)); Proj::Pt3 pt_proj (persp->tmat.preimage (new_pos_snapped, box3d_get_proj_corner (box, id)[(movement & Box3D::Y) ? Proj::X : Proj::Y], (movement & Box3D::Y) ? Proj::X : Proj::Y)); @@ -577,7 +577,7 @@ box3d_set_corner (SPBox3D *box, const guint id, NR::Point const &new_pos, const // FIXME: Should we update the box here? If so, how? } -void box3d_set_center (SPBox3D *box, NR::Point const &new_pos, NR::Point const &old_pos, const Box3D::Axis movement, bool constrained) { +void box3d_set_center (SPBox3D *box, Geom::Point const &new_pos, Geom::Point const &old_pos, const Box3D::Axis movement, bool constrained) { g_return_if_fail ((movement != Box3D::NONE) && (movement != Box3D::XYZ)); box->orig_corner0.normalize(); @@ -610,7 +610,7 @@ void box3d_set_center (SPBox3D *box, NR::Point const &new_pos, NR::Point const & double radz = (box->orig_corner7[Proj::Z] - box->orig_corner0[Proj::Z]) / 2; Box3D::PerspectiveLine pl(old_pos, Proj::Z, persp); - NR::Point new_pos_snapped(pl.closest_to(new_pos)); + Geom::Point new_pos_snapped(pl.closest_to(new_pos)); Proj::Pt3 pt_proj (persp->tmat.preimage (new_pos_snapped, coord, Proj::X)); /* normalizing pt_proj is essential because we want to mingle affine coordinates */ @@ -631,7 +631,7 @@ void box3d_set_center (SPBox3D *box, NR::Point const &new_pos, NR::Point const & * from which the perspective lines in the direction of 'axis' emerge */ void box3d_corners_for_PLs (const SPBox3D * box, Proj::Axis axis, - NR::Point &corner1, NR::Point &corner2, NR::Point &corner3, NR::Point &corner4) + Geom::Point &corner1, Geom::Point &corner2, Geom::Point &corner3, Geom::Point &corner4) { Persp3D *persp = box3d_get_perspective(box); g_return_if_fail (persp); @@ -708,8 +708,8 @@ box3d_XY_axes_are_swapped (SPBox3D *box) { g_return_val_if_fail(persp, false); Box3D::PerspectiveLine l1(box3d_get_corner_screen(box, 3, false), Proj::X, persp); Box3D::PerspectiveLine l2(box3d_get_corner_screen(box, 3, false), Proj::Y, persp); - NR::Point v1(l1.direction()); - NR::Point v2(l2.direction()); + Geom::Point v1(l1.direction()); + Geom::Point v2(l2.direction()); v1.normalize(); v2.normalize(); @@ -750,9 +750,9 @@ box3d_swap_z_orders (int z_orders[6]) { static void box3d_set_new_z_orders_case0 (SPBox3D *box, int z_orders[6], Box3D::Axis central_axis) { Persp3D *persp = box3d_get_perspective(box); - NR::Point xdir(persp3d_get_infinite_dir(persp, Proj::X)); - NR::Point ydir(persp3d_get_infinite_dir(persp, Proj::Y)); - NR::Point zdir(persp3d_get_infinite_dir(persp, Proj::Z)); + Geom::Point xdir(persp3d_get_infinite_dir(persp, Proj::X)); + Geom::Point ydir(persp3d_get_infinite_dir(persp, Proj::Y)); + Geom::Point zdir(persp3d_get_infinite_dir(persp, Proj::Z)); bool swapped = box3d_XY_axes_are_swapped(box); @@ -795,7 +795,7 @@ box3d_set_new_z_orders_case0 (SPBox3D *box, int z_orders[6], Box3D::Axis central static void box3d_set_new_z_orders_case1 (SPBox3D *box, int z_orders[6], Box3D::Axis central_axis, Box3D::Axis fin_axis) { Persp3D *persp = box3d_get_perspective(box); - NR::Point vp(persp3d_get_VP(persp, Box3D::toProj(fin_axis)).affine()); + Geom::Point vp(persp3d_get_VP(persp, Box3D::toProj(fin_axis)).affine()); // note: in some of the case distinctions below we rely upon the fact that oaxis1 and oaxis2 are ordered Box3D::Axis oaxis1 = Box3D::get_remaining_axes(fin_axis).first; @@ -867,10 +867,10 @@ static void box3d_set_new_z_orders_case2 (SPBox3D *box, int z_orders[6], Box3D::Axis central_axis, Box3D::Axis /*infinite_axis*/) { Persp3D *persp = box3d_get_perspective(box); - NR::Point c3(box3d_get_corner_screen(box, 3, false)); - NR::Point xdir(persp3d_get_PL_dir_from_pt(persp, c3, Proj::X)); - NR::Point ydir(persp3d_get_PL_dir_from_pt(persp, c3, Proj::Y)); - NR::Point zdir(persp3d_get_PL_dir_from_pt(persp, c3, Proj::Z)); + Geom::Point c3(box3d_get_corner_screen(box, 3, false)); + Geom::Point xdir(persp3d_get_PL_dir_from_pt(persp, c3, Proj::X)); + Geom::Point ydir(persp3d_get_PL_dir_from_pt(persp, c3, Proj::Y)); + Geom::Point zdir(persp3d_get_PL_dir_from_pt(persp, c3, Proj::Z)); bool swapped = box3d_XY_axes_are_swapped(box); @@ -1002,13 +1002,13 @@ box3d_recompute_z_orders (SPBox3D *box) { int z_orders[6]; - NR::Point c3(box3d_get_corner_screen(box, 3, false)); + Geom::Point c3(box3d_get_corner_screen(box, 3, false)); // determine directions from corner3 to the VPs int num_finite = 0; Box3D::Axis axis_finite = Box3D::NONE; Box3D::Axis axis_infinite = Box3D::NONE; - NR::Point dirs[3]; + Geom::Point dirs[3]; for (int i = 0; i < 3; ++i) { dirs[i] = persp3d_get_PL_dir_from_pt(persp, c3, Box3D::toProj(Box3D::axes[i])); if (persp3d_VP_is_finite(persp, Proj::axes[i])) { @@ -1048,16 +1048,16 @@ box3d_recompute_z_orders (SPBox3D *box) { * joining the other two VPs. If this is the case, it determines the "central" corner from * which the visible sides can be deduced. Otherwise, corner3 is the central corner. */ - // FIXME: We should eliminate the use of NR::Point altogether + // FIXME: We should eliminate the use of Geom::Point altogether Box3D::Axis central_axis = Box3D::NONE; - NR::Point vp_x = persp3d_get_VP(persp, Proj::X).affine(); - NR::Point vp_y = persp3d_get_VP(persp, Proj::Y).affine(); - NR::Point vp_z = persp3d_get_VP(persp, Proj::Z).affine(); + Geom::Point vp_x = persp3d_get_VP(persp, Proj::X).affine(); + Geom::Point vp_y = persp3d_get_VP(persp, Proj::Y).affine(); + Geom::Point vp_z = persp3d_get_VP(persp, Proj::Z).affine(); Geom::Point vpx(vp_x[NR::X], vp_x[NR::Y]); Geom::Point vpy(vp_y[NR::X], vp_y[NR::Y]); Geom::Point vpz(vp_z[NR::X], vp_z[NR::Y]); - NR::Point c3 = box3d_get_corner_screen(box, 3, false); + Geom::Point c3 = box3d_get_corner_screen(box, 3, false); Geom::Point corner3(c3[NR::X], c3[NR::Y]); if (box3d_half_line_crosses_joining_line (corner3, vpx, vpy, vpz)) { @@ -1076,9 +1076,9 @@ box3d_recompute_z_orders (SPBox3D *box) { central_corner = central_corner ^ Box3D::XYZ; } - NR::Point c1(box3d_get_corner_screen(box, 1, false)); - NR::Point c2(box3d_get_corner_screen(box, 2, false)); - NR::Point c7(box3d_get_corner_screen(box, 7, false)); + Geom::Point c1(box3d_get_corner_screen(box, 1, false)); + Geom::Point c2(box3d_get_corner_screen(box, 2, false)); + Geom::Point c7(box3d_get_corner_screen(box, 7, false)); Geom::Point corner1(c1[NR::X], c1[NR::Y]); Geom::Point corner2(c2[NR::X], c2[NR::Y]); @@ -1188,19 +1188,19 @@ box3d_set_z_orders (SPBox3D *box) { // TODO: Maybe it would be useful to have a similar method for projective points pt because then we // can use it for VPs and perhaps merge the case distinctions during z-order recomputation. int -box3d_pt_lies_in_PL_sector (SPBox3D const *box, NR::Point const &pt, int id1, int id2, Box3D::Axis axis) { +box3d_pt_lies_in_PL_sector (SPBox3D const *box, Geom::Point const &pt, int id1, int id2, Box3D::Axis axis) { Persp3D *persp = box3d_get_perspective(box); // the two corners - NR::Point c1(box3d_get_corner_screen(box, id1, false)); - NR::Point c2(box3d_get_corner_screen(box, id2, false)); + Geom::Point c1(box3d_get_corner_screen(box, id1, false)); + Geom::Point c2(box3d_get_corner_screen(box, id2, false)); int ret = 0; if (persp3d_VP_is_finite(persp, Box3D::toProj(axis))) { - NR::Point vp(persp3d_get_VP(persp, Box3D::toProj(axis)).affine()); - NR::Point v1(c1 - vp); - NR::Point v2(c2 - vp); - NR::Point w(pt - vp); + Geom::Point vp(persp3d_get_VP(persp, Box3D::toProj(axis)).affine()); + Geom::Point v1(c1 - vp); + Geom::Point v2(c2 - vp); + Geom::Point w(pt - vp); ret = static_cast(Box3D::lies_in_sector(v1, v2, w)); } else { Box3D::PerspectiveLine pl1(c1, Box3D::toProj(axis), persp); @@ -1208,7 +1208,7 @@ box3d_pt_lies_in_PL_sector (SPBox3D const *box, NR::Point const &pt, int id1, in if (pl1.lie_on_same_side(pt, c2) && pl2.lie_on_same_side(pt, c1)) { // test whether pt lies "towards" or "away from" the VP Box3D::Line edge(c1,c2); - NR::Point c3(box3d_get_corner_screen(box, id1 ^ axis, false)); + Geom::Point c3(box3d_get_corner_screen(box, id1 ^ axis, false)); if (edge.lie_on_same_side(pt, c3)) { ret = 1; } else { @@ -1341,8 +1341,8 @@ box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, box->orig_corner7.normalize(); double z0 = box->orig_corner0[Proj::Z]; double z7 = box->orig_corner7[Proj::Z]; - NR::Point corner0_screen = box3d_get_corner_screen(box, 0, false); - NR::Point corner7_screen = box3d_get_corner_screen(box, 7, false); + Geom::Point corner0_screen = box3d_get_corner_screen(box, 0, false); + Geom::Point corner7_screen = box3d_get_corner_screen(box, 7, false); box->orig_corner0 = new_persp->tmat.preimage(corner0_screen, z0, Proj::Z); box->orig_corner7 = new_persp->tmat.preimage(corner7_screen, z7, Proj::Z); diff --git a/src/box3d.h b/src/box3d.h index 953275679..b6d962a3c 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -54,17 +54,17 @@ GType box3d_get_type (void); void box3d_position_set (SPBox3D *box); Proj::Pt3 box3d_get_proj_corner (SPBox3D const *box, guint id); -NR::Point box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords = true); +Geom::Point box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords = true); Proj::Pt3 box3d_get_proj_center (SPBox3D *box); -NR::Point box3d_get_center_screen (SPBox3D *box); +Geom::Point box3d_get_center_screen (SPBox3D *box); -void box3d_set_corner (SPBox3D *box, guint id, NR::Point const &new_pos, Box3D::Axis movement, bool constrained); -void box3d_set_center (SPBox3D *box, NR::Point const &new_pos, NR::Point const &old_pos, Box3D::Axis movement, bool constrained); -void box3d_corners_for_PLs (const SPBox3D * box, Proj::Axis axis, NR::Point &corner1, NR::Point &corner2, NR::Point &corner3, NR::Point &corner4); +void box3d_set_corner (SPBox3D *box, guint id, Geom::Point const &new_pos, Box3D::Axis movement, bool constrained); +void box3d_set_center (SPBox3D *box, Geom::Point const &new_pos, Geom::Point const &old_pos, Box3D::Axis movement, bool constrained); +void box3d_corners_for_PLs (const SPBox3D * box, Proj::Axis axis, Geom::Point &corner1, Geom::Point &corner2, Geom::Point &corner3, Geom::Point &corner4); bool box3d_recompute_z_orders (SPBox3D *box); void box3d_set_z_orders (SPBox3D *box); -int box3d_pt_lies_in_PL_sector (SPBox3D const *box, NR::Point const &pt, int id1, int id2, Box3D::Axis axis); +int box3d_pt_lies_in_PL_sector (SPBox3D const *box, Geom::Point const &pt, int id1, int id2, Box3D::Axis axis); int box3d_VP_lies_in_PL_sector (SPBox3D const *box, Proj::Axis vpdir, int id1, int id2, Box3D::Axis axis); void box3d_relabel_corners(SPBox3D *box); diff --git a/src/persp3d.cpp b/src/persp3d.cpp index ec4244f6b..71d12619b 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -288,7 +288,7 @@ persp3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: } /* convenience wrapper around persp3d_get_finite_dir() and persp3d_get_infinite_dir() */ -NR::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, NR::Point const &pt, Proj::Axis axis) { +Geom::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis) { if (persp3d_VP_is_finite(persp, axis)) { return persp3d_get_finite_dir(persp, pt, axis); } else { @@ -296,20 +296,20 @@ NR::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, NR::Point const &pt, Proj: } } -NR::Point -persp3d_get_finite_dir (Persp3D *persp, NR::Point const &pt, Proj::Axis axis) { +Geom::Point +persp3d_get_finite_dir (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis) { Box3D::PerspectiveLine pl(pt, axis, persp); return pl.direction(); } -NR::Point +Geom::Point persp3d_get_infinite_dir (Persp3D *persp, Proj::Axis axis) { Proj::Pt2 vp(persp3d_get_VP(persp, axis)); if (vp[2] != 0.0) { g_print ("VP should be infinite but is (%f : %f : %f)\n", vp[0], vp[1], vp[2]); - g_return_val_if_fail(vp[2] != 0.0, NR::Point(0.0, 0.0)); + g_return_val_if_fail(vp[2] != 0.0, Geom::Point(0.0, 0.0)); } - return NR::Point(vp[0], vp[1]); + return Geom::Point(vp[0], vp[1]); } double @@ -361,8 +361,8 @@ persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_press return; } Proj::Pt2 v_dir_proj (persp->tmat.column(axis)); - NR::Point v_dir (v_dir_proj[0], v_dir_proj[1]); - double a = NR::atan2 (v_dir) * 180/M_PI; + Geom::Point v_dir (v_dir_proj[0], v_dir_proj[1]); + double a = Geom::atan2 (v_dir) * 180/M_PI; a += alt_pressed ? 0.5 * ((angle > 0 ) - (angle < 0)) : angle; // the r.h.s. yields +/-0.5 or angle persp->tmat.set_infinite_direction (axis, a); @@ -376,7 +376,7 @@ persp3d_update_with_point (Persp3D *persp, Proj::Axis const axis, Proj::Pt2 cons } void -persp3d_apply_affine_transformation (Persp3D *persp, NR::Matrix const &xform) { +persp3d_apply_affine_transformation (Persp3D *persp, Geom::Matrix const &xform) { persp->tmat *= xform; persp3d_update_box_reprs(persp); SP_OBJECT(persp)->updateRepr(SP_OBJECT_WRITE_EXT); diff --git a/src/persp3d.h b/src/persp3d.h index c0fabc092..79bec0232 100644 --- a/src/persp3d.h +++ b/src/persp3d.h @@ -56,9 +56,9 @@ inline Persp3D * persp3d_get_from_repr (Inkscape::XML::Node *repr) { inline Proj::Pt2 persp3d_get_VP (Persp3D *persp, Proj::Axis axis) { return persp->tmat.column(axis); } -NR::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, NR::Point const &pt, Proj::Axis axis); // convenience wrapper around the following two -NR::Point persp3d_get_finite_dir (Persp3D *persp, NR::Point const &pt, Proj::Axis axis); -NR::Point persp3d_get_infinite_dir (Persp3D *persp, Proj::Axis axis); +Geom::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis); // convenience wrapper around the following two +Geom::Point persp3d_get_finite_dir (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis); +Geom::Point persp3d_get_infinite_dir (Persp3D *persp, Proj::Axis axis); double persp3d_get_infinite_angle (Persp3D *persp, Proj::Axis axis); bool persp3d_VP_is_finite (Persp3D *persp, Proj::Axis axis); void persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo = true); @@ -66,7 +66,7 @@ void persp3d_toggle_VPs (std::list, Proj::Axis axis); void persp3d_set_VP_state (Persp3D *persp, Proj::Axis axis, Proj::VPState state); void persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_pressed); // angle is in degrees void persp3d_update_with_point (Persp3D *persp, Proj::Axis const axis, Proj::Pt2 const &new_image); -void persp3d_apply_affine_transformation (Persp3D *persp, NR::Matrix const &xform); +void persp3d_apply_affine_transformation (Persp3D *persp, Geom::Matrix const &xform); gchar * persp3d_pt_to_str (Persp3D *persp, Proj::Axis const axis); void persp3d_add_box (Persp3D *persp, SPBox3D *box); diff --git a/src/perspective-line.cpp b/src/perspective-line.cpp index 051a1d94a..3e7d96fdd 100644 --- a/src/perspective-line.cpp +++ b/src/perspective-line.cpp @@ -16,14 +16,14 @@ namespace Box3D { -PerspectiveLine::PerspectiveLine (NR::Point const &pt, Proj::Axis const axis, Persp3D *persp) : +PerspectiveLine::PerspectiveLine (Geom::Point const &pt, Proj::Axis const axis, Persp3D *persp) : Line (pt, persp3d_get_VP(persp, axis).affine(), true) { g_assert (persp != NULL); if (!persp3d_get_VP(persp, axis).is_finite()) { Proj::Pt2 vp(persp3d_get_VP(persp, axis)); - this->set_direction(NR::Point(vp[Proj::X], vp[Proj::Y])); + this->set_direction(Geom::Point(vp[Proj::X], vp[Proj::Y])); } this->vp_dir = axis; this->persp = persp; diff --git a/src/perspective-line.h b/src/perspective-line.h index e0235aafc..57abaae9c 100644 --- a/src/perspective-line.h +++ b/src/perspective-line.h @@ -27,7 +27,7 @@ public: * PL runs through it; otherwise it has the direction specified by the v_dir vector * of the VP. */ - PerspectiveLine (NR::Point const &pt, Proj::Axis const axis, Persp3D *persp); + PerspectiveLine (Geom::Point const &pt, Proj::Axis const axis, Persp3D *persp); private: Proj::Axis vp_dir; // direction of the associated VP diff --git a/src/proj_pt.cpp b/src/proj_pt.cpp index d7906a4e2..9294046ab 100644 --- a/src/proj_pt.cpp +++ b/src/proj_pt.cpp @@ -45,12 +45,12 @@ Pt2::normalize() { pt[2] = 1.0; } -NR::Point +Geom::Point Pt2::affine() { if (fabs(pt[2]) < epsilon) { - return NR::Point (NR_HUGE, NR_HUGE); + return Geom::Point (NR_HUGE, NR_HUGE); } - return NR::Point (pt[0]/pt[2], pt[1]/pt[2]); + return Geom::Point (pt[0]/pt[2], pt[1]/pt[2]); } gchar * diff --git a/src/proj_pt.h b/src/proj_pt.h index b14dea50e..844cbb2c4 100644 --- a/src/proj_pt.h +++ b/src/proj_pt.h @@ -13,7 +13,6 @@ */ #include <2geom/point.h> -#include "libnr/nr-point.h" #include "libnr/nr-values.h" #include @@ -26,7 +25,6 @@ class Pt2 { public: Pt2 () { pt[0] = 0; pt[1] = 0; pt[2] = 1.0; } // we default to (0 : 0 : 1) Pt2 (double x, double y, double w) { pt[0] = x; pt[1] = y; pt[2] = w; } - Pt2 (NR::Point const &point) { pt[0] = point[NR::X]; pt[1] = point[NR::Y]; pt[2] = 1; } Pt2 (Geom::Point const &point) { pt[0] = point[Geom::X]; pt[1] = point[Geom::Y]; pt[2] = 1; } Pt2 (const gchar *coord_str); @@ -82,7 +80,7 @@ public: } void normalize(); - NR::Point affine(); + Geom::Point affine(); inline bool is_finite() { return pt[2] != 0; } // FIXME: Should we allow for some tolerance? gchar *coord_string(); inline void print(gchar const *s) const { g_print ("%s(%8.2f : %8.2f : %8.2f)\n", s, pt[0], pt[1], pt[2]); } diff --git a/src/transf_mat_3x4.cpp b/src/transf_mat_3x4.cpp index ec03b0de6..b7cd278d4 100644 --- a/src/transf_mat_3x4.cpp +++ b/src/transf_mat_3x4.cpp @@ -13,9 +13,9 @@ #include "transf_mat_3x4.h" #include +#include <2geom/matrix.h> #include "svg/stringstream.h" #include "syseq.h" -#include "libnr/nr-matrix.h" #include "document.h" #include "inkscape.h" @@ -61,11 +61,11 @@ TransfMat3x4::image (Pt3 const &point) { } Pt3 -TransfMat3x4::preimage (NR::Point const &pt, double coord, Proj::Axis axis) { +TransfMat3x4::preimage (Geom::Point const &pt, double coord, Proj::Axis axis) { double x[4]; double v[3]; - v[0] = pt[NR::X]; - v[1] = pt[NR::Y]; + v[0] = pt[Geom::X]; + v[1] = pt[Geom::Y]; v[2] = 1.0; int index = (int) axis; @@ -93,10 +93,10 @@ void TransfMat3x4::toggle_finite (Proj::Axis axis) { g_return_if_fail (axis != Proj::W); if (has_finite_image(axis)) { - NR::Point dir (column(axis).affine()); - NR::Point origin (column(Proj::W).affine()); + Geom::Point dir (column(axis).affine()); + Geom::Point origin (column(Proj::W).affine()); dir -= origin; - set_column (axis, Proj::Pt2(dir[NR::X], dir[NR::Y], 0)); + set_column (axis, Proj::Pt2(dir[Geom::X], dir[Geom::Y], 0)); } else { Proj::Pt2 dir (column(axis)); Proj::Pt2 origin (column(Proj::W).affine()); @@ -131,7 +131,7 @@ TransfMat3x4::operator==(const TransfMat3x4 &rhs) const /* multiply a projective matrix by an affine matrix */ TransfMat3x4 -TransfMat3x4::operator*(NR::Matrix const &A) const { +TransfMat3x4::operator*(Geom::Matrix const &A) const { TransfMat3x4 ret; // Is it safe to always use the currently active document? @@ -141,7 +141,7 @@ TransfMat3x4::operator*(NR::Matrix const &A) const { * Note: The strange multiplication involving the document height is due to the buggy * intertwining of SVG and document coordinates. Essentially, what we do is first * convert from "real-world" to SVG coordinates, then apply the transformation A - * (by multiplying with the NR::Matrix) and then convert back from SVG to real-world + * (by multiplying with the Geom::Matrix) and then convert back from SVG to real-world * coordinates. Maybe there is even a more Inkscape-ish way to achieve this? * Once Inkscape has gotton rid of the two different coordiate systems, we can change * this function to an ordinary matrix multiplication. @@ -160,7 +160,7 @@ TransfMat3x4::operator*(NR::Matrix const &A) const { // FIXME: Shouldn't rather operator* call operator*= for efficiency? (Because in operator*= // there is in principle no need to create a temporary object, which happens in the assignment) TransfMat3x4 & -TransfMat3x4::operator*=(NR::Matrix const &A) { +TransfMat3x4::operator*=(Geom::Matrix const &A) { *this = *this * A; return *this; } diff --git a/src/transf_mat_3x4.h b/src/transf_mat_3x4.h index 58d332cb9..53c9ffa81 100644 --- a/src/transf_mat_3x4.h +++ b/src/transf_mat_3x4.h @@ -12,7 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "libnr/nr-point-fns.h" #include "proj_pt.h" #include "axis-manip.h" @@ -25,22 +24,22 @@ public: TransfMat3x4(TransfMat3x4 const &rhs); Pt2 column (Proj::Axis axis) const; Pt2 image (Pt3 const &point); - Pt3 preimage (NR::Point const &pt, double coord = 0, Axis = Z); + Pt3 preimage (Geom::Point const &pt, double coord = 0, Axis = Z); void set_image_pt (Proj::Axis axis, Proj::Pt2 const &pt); void toggle_finite (Proj::Axis axis); double get_infinite_angle (Proj::Axis axis) { if (has_finite_image(axis)) { - return NR_HUGE; + return 1e18; //this used to be NR_HUGE before 2geom conversion } Pt2 vp(column(axis)); - return NR::atan2(NR::Point(vp[0], vp[1])) * 180.0/M_PI; + return Geom::atan2(Geom::Point(vp[0], vp[1])) * 180.0/M_PI; } void set_infinite_direction (Proj::Axis axis, double angle) { // angle is in degrees g_return_if_fail(tmat[2][axis] == 0); // don't set directions for finite VPs double a = angle * M_PI/180; - NR::Point pt(tmat[0][axis], tmat[1][axis]); - double rad = NR::L2(pt); + Geom::Point pt(tmat[0][axis], tmat[1][axis]); + double rad = Geom::L2(pt); set_image_pt(axis, Proj::Pt2(cos (a) * rad, sin (a) * rad, 0.0)); } inline bool has_finite_image (Proj::Axis axis) { return (tmat[2][axis] != 0.0); } @@ -48,8 +47,8 @@ public: gchar * pt_to_str (Proj::Axis axis); bool operator==(const TransfMat3x4 &rhs) const; - TransfMat3x4 operator*(NR::Matrix const &A) const; - TransfMat3x4 &operator*=(NR::Matrix const &A); + TransfMat3x4 operator*(Geom::Matrix const &A) const; + TransfMat3x4 &operator*=(Geom::Matrix const &A); void print() const; diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index ac123792d..14bf8d161 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -77,12 +77,12 @@ have_VPs_of_same_perspective (VPDragger *dr1, VPDragger *dr2) } static void -vp_knot_moved_handler (SPKnot */*knot*/, NR::Point const *ppointer, guint state, gpointer data) +vp_knot_moved_handler (SPKnot */*knot*/, Geom::Point const *ppointer, guint state, gpointer data) { VPDragger *dragger = (VPDragger *) data; VPDrag *drag = dragger->parent; - NR::Point p = *ppointer; + Geom::Point p = *ppointer; // FIXME: take from prefs double snap_dist = SNAP_DIST / inkscape_active_desktop()->current_zoom(); @@ -248,7 +248,7 @@ VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { return sel_boxes; } -VPDragger::VPDragger(VPDrag *parent, NR::Point p, VanishingPoint &vp) +VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp) { this->parent = parent; @@ -440,7 +440,7 @@ VPDragger::updateBoxDisplays () } void -VPDragger::updateVPs (NR::Point const &pt) +VPDragger::updateVPs (Geom::Point const &pt) { for (std::list::iterator i = this->vps.begin(); i != this->vps.end(); ++i) { (*i).set_pos (pt); @@ -657,14 +657,14 @@ VPDrag::drawLinesForFace (const SPBox3D *box, Proj::Axis axis) //, guint corner1 default: g_assert_not_reached(); } - NR::Point corner1, corner2, corner3, corner4; + Geom::Point corner1, corner2, corner3, corner4; box3d_corners_for_PLs (box, axis, corner1, corner2, corner3, corner4); g_return_if_fail (box3d_get_perspective(box)); Proj::Pt2 vp = persp3d_get_VP (box3d_get_perspective(box), axis); if (vp.is_finite()) { // draw perspective lines for finite VPs - NR::Point pt = vp.affine(); + Geom::Point pt = vp.affine(); if (this->front_or_rear_lines & 0x1) { // draw 'front' perspective lines this->addLine (corner1, pt, color); @@ -677,7 +677,7 @@ VPDrag::drawLinesForFace (const SPBox3D *box, Proj::Axis axis) //, guint corner1 } } else { // draw perspective lines for infinite VPs - boost::optional pt1, pt2, pt3, pt4; + boost::optional pt1, pt2, pt3, pt4; Persp3D *persp = box3d_get_perspective(box); SPDesktop *desktop = inkscape_active_desktop (); // FIXME: Store the desktop in VPDrag Box3D::PerspectiveLine pl (corner1, axis, persp); @@ -721,7 +721,7 @@ VPDrag::addDragger (VanishingPoint &vp) // don't create draggers for infinite vanishing points return; } - NR::Point p = vp.get_pos(); + Geom::Point p = vp.get_pos(); for (GList *i = this->draggers; i != NULL; i = i->next) { VPDragger *dragger = (VPDragger *) i->data; @@ -755,7 +755,7 @@ VPDrag::swap_perspectives_of_VPs(Persp3D *persp2, Persp3D *persp1) Create a line from p1 to p2 and add it to the lines list */ void -VPDrag::addLine (NR::Point p1, NR::Point p2, guint32 rgba) +VPDrag::addLine (Geom::Point p1, Geom::Point p2, guint32 rgba) { SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(inkscape_active_desktop()), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_coords(SP_CTRLLINE(line), p1, p2); diff --git a/src/vanishing-point.h b/src/vanishing-point.h index aef5f6f5c..9fcb6bb46 100644 --- a/src/vanishing-point.h +++ b/src/vanishing-point.h @@ -13,7 +13,7 @@ #define SEEN_VANISHING_POINT_H #include -#include "libnr/nr-point.h" +#include <2geom/point.h> #include "knot.h" #include "selection.h" #include "axis-manip.h" @@ -66,8 +66,8 @@ public: g_return_val_if_fail (_persp, false); return persp3d_get_VP (_persp, _axis).is_finite(); } - inline NR::Point get_pos() const { - g_return_val_if_fail (_persp, NR::Point (NR_HUGE, NR_HUGE)); + inline Geom::Point get_pos() const { + g_return_val_if_fail (_persp, Geom::Point (NR_HUGE, NR_HUGE)); return persp3d_get_VP (_persp,_axis).affine(); } inline Persp3D * get_perspective() const { @@ -122,16 +122,16 @@ struct less_ptr : public std::binary_function