Code

remove extra Shape:: on new function definition in Shape class.
[inkscape.git] / src / line-geometry.h
1 /*
2  * Routines for dealing with lines (intersections, etc.)
3  *
4  * Authors:
5  *   Maximilian Albert <Anhalter42@gmx.de>
6  *
7  * Copyright (C) 2007 authors
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #ifndef SEEN_LINE_GEOMETRY_H
13 #define SEEN_LINE_GEOMETRY_H
15 #include "libnr/nr-point.h"
16 #include "libnr/nr-point-fns.h"
17 #include "libnr/nr-maybe.h"
18 #include "glib.h"
19 #include "display/sp-ctrlline.h"
20 #include "vanishing-point.h"
22 #include "document.h"
23 #include "ui/view/view.h"
25 namespace Box3D {
27 class Line {
28 public:
29     Line(NR::Point const &start, NR::Point const &vec, bool is_endpoint = true);
30     Line(Line const &line);
31     Line &operator=(Line const &line);
32     virtual NR::Maybe<NR::Point> intersect(Line const &line);
33     void set_direction(NR::Point const &dir); // FIXME: Can we avoid this explicit assignment?
34     
35     NR::Point closest_to(NR::Point const &pt); // returns the point on the line closest to pt 
37     friend inline std::ostream &operator<< (std::ostream &out_file, const Line &in_line);
38         
39 private:
40     NR::Point pt;
41     NR::Point v_dir;
42     NR::Point normal;
43     NR::Coord d0;
44 };
46 /*** For testing purposes: Draw a knot/node of specified size and color at the given position ***/
47 void create_canvas_point(NR::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f);
49 /*** For testing purposes: Draw a line between the specified points ***/
50 void create_canvas_line(NR::Point const &p1, NR::Point const &p2, guint32 rgba = 0xff00007f);
53 /** A function to print out the Line.  It just prints out the coordinates of start point and
54     direction on the given output stream */
55 inline std::ostream &operator<< (std::ostream &out_file, const Line &in_line) {
56     out_file << "Start: " << in_line.pt << "  Direction: " << in_line.v_dir;
57     return out_file;
58 }
60 } // namespace Box3D
63 #endif /* !SEEN_LINE_GEOMETRY_H */
65 /*
66   Local Variables:
67   mode:c++
68   c-file-style:"stroustrup"
69   c-file-offsets:((innamespace . 0)(inline-open . 0))
70   indent-tabs-mode:nil
71   fill-column:99
72   End:
73 */
74 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :