Code

Mnemonics in "Fill and stroke", "Align and distribute", and "Transform" dialogs ...
[inkscape.git] / src / perspective-line.cpp
index 9ee2d3578664005ae10042d948a95a2e6cce2a92..4fd68f8edbf8b51d6f3cda8f05b9a11bf4702a30 100644 (file)
  */
 
 #include "perspective-line.h"
-#include "desktop.h"
+#include "persp3d.h"
 
 namespace Box3D {
 
-PerspectiveLine::PerspectiveLine (NR::Point const &pt, Box3D::Axis const axis, Perspective3D *perspective) :
-        Line (pt, *(perspective->get_vanishing_point(axis)), true)
+PerspectiveLine::PerspectiveLine (Geom::Point const &pt, Proj::Axis const axis, Persp3D *persp) :
+        Line (pt, persp3d_get_VP(persp, axis).affine(), true)
 {
-    g_assert (perspective != NULL);
-    g_assert (Box3D::is_single_axis_direction (axis));
+    g_assert (persp != NULL);
 
-    if (perspective->get_vanishing_point(axis)->state == VP_INFINITE) {
-        this->set_direction(perspective->get_vanishing_point(axis)->v_dir);
+    if (!persp3d_get_VP(persp, axis).is_finite()) {
+        Proj::Pt2 vp(persp3d_get_VP(persp, axis));
+        this->set_direction(Geom::Point(vp[Proj::X], vp[Proj::Y]));
     }
     this->vp_dir = axis;
-    this->persp  = perspective;
-}
-
-// This function makes sure not to return NR::Nothing()
-// FIXME: How to gracefully handle parallel lines?
-NR::Maybe<NR::Point> PerspectiveLine::intersect (Line const &line)
-{
-    NR::Maybe<NR::Point> pt = this->Line::intersect(line);
-    if (!pt) {
-        Box3D::VanishingPoint vp = *(persp->get_vanishing_point(vp_dir));
-        if (vp.state == VP_INFINITE) {
-            pt = vp;
-        } else {
-            pt = NR::Point (0.0, 0.0); // FIXME: Better solution needed
-        }
-    }
-    return pt; 
-}
-
-// FIXME: Do we really need two intersection methods?
-NR::Point PerspectiveLine::meet(Line const &line)
-{
-    return *intersect(line); // works since intersect() does not return NR::Nothing()
-}
-
-NR::Maybe<NR::Point> PerspectiveLine::intersection_with_viewbox (SPDesktop *desktop)
-{
-    NR::Rect vb = desktop->get_display_area();
-    /* remaining viewbox corners */
-    NR::Point ul (vb.min()[NR::X], vb.max()[NR::Y]);
-    NR::Point lr (vb.max()[NR::X], vb.min()[NR::Y]);
-
-    std::pair <NR::Point, NR::Point> e = side_of_intersection (vb.min(), lr, vb.max(), ul, this->pt, this->v_dir);
-    if (e.first == e.second) {
-        // perspective line lies outside the canvas
-        return NR::Nothing();
-    }
-
-    Line line (e.first, e.second);
-    return this->intersect (line);
+    this->persp  = persp;
 }
 
 } // namespace Box3D 
@@ -79,4 +40,4 @@ NR::Maybe<NR::Point> PerspectiveLine::intersection_with_viewbox (SPDesktop *desk
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :