Code

First stage of draggable vanishing points (no snapping/unsnapping yet)
[inkscape.git] / src / perspective3d.h
1 /*
2  * Class modelling a 3D perspective
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_PERSPECTIVE3D_H
13 #define SEEN_PERSPECTIVE3D_H
15 #include "vanishing-point.h"
16 #include "svg/stringstream.h"
18 class SP3DBox;
20 namespace Box3D {
22 class PerspectiveLine;
24 class Perspective3D {
25 public:
26     Perspective3D(VanishingPoint const &pt_x, VanishingPoint const &pt_y, VanishingPoint const &pt_z);
27     Perspective3D(Perspective3D &other);
28     ~Perspective3D();
30     bool operator== (Perspective3D const &other);
32     VanishingPoint *get_vanishing_point (Box3D::Axis const dir);
33     Axis get_axis_of_VP (VanishingPoint *vp);
34     void set_vanishing_point (Box3D::Axis const dir, VanishingPoint const &pt);
35     void set_vanishing_point (Box3D::Axis const dir, gdouble pt_x, gdouble pt_y, gdouble dir_x, gdouble dir_y, VPState st);
36     void add_box (SP3DBox *box);
37     void remove_box (const SP3DBox *box);
38     bool has_box (const SP3DBox *box);
39     void reshape_boxes (Box3D::Axis axes);
40     void update_box_reprs ();
42     static gint counter; // for testing only
43     gint my_counter; // for testing only
45     static GSList * perspectives; // All existing 3D perspectives
46     static void add_perspective (Box3D::Perspective3D * const persp);
47     static void remove_perspective (Box3D::Perspective3D * const persp);
48     static Box3D::Perspective3D * find_perspective (Box3D::Perspective3D * const persp); // find an existing perspective whose VPs are equal to those of persp
50     static void print_debugging_info();
51     static Perspective3D * current_perspective;
53 private:
54     VanishingPoint *vp_x;
55     VanishingPoint *vp_y;
56     VanishingPoint *vp_z;
57     GSList * boxes; // holds a list of boxes sharing this specific perspective
58 };
60 Perspective3D * get_persp_of_box (const SP3DBox *box);
61 Perspective3D * get_persp_of_VP (const VanishingPoint *vp);
63 NR::Point perspective_intersection (NR::Point pt1, Box3D::Axis dir1, NR::Point pt2, Box3D::Axis dir2, Perspective3D *persp);
64 NR::Point perspective_line_snap (NR::Point pt, Box3D::Axis dir, NR::Point ext_pt, Perspective3D *persp);
66 } // namespace Box3D
69 /** A function to print out the VanishingPoint (prints the coordinates) **/
70 /***
71 inline std::ostream &operator<< (std::ostream &out_file, const VanishingPoint &vp) {
72     out_file << vp;
73     return out_file;
74 }
75 ***/
78 #endif /* !SEEN_PERSPECTIVE3D_H */
80 /*
81   Local Variables:
82   mode:c++
83   c-file-style:"stroustrup"
84   c-file-offsets:((innamespace . 0)(inline-open . 0))
85   indent-tabs-mode:nil
86   fill-column:99
87   End:
88 */
89 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :