Code

If necessary, split up perspectives when applying transformations to boxes; moreover...
[inkscape.git] / src / persp3d.h
1 #ifndef __PERSP3D_H__
2 #define __PERSP3D_H__
4 /*
5  * Implementation of 3D perspectives as SPObjects
6  *
7  * Authors:
8  *   Maximilian Albert <Anhalter42@gmx.de>
9  *
10  * Copyright (C) 2007  Authors
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #define SP_TYPE_PERSP3D         (persp3d_get_type ())
16 #define SP_PERSP3D(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_PERSP3D, Persp3D))
17 #define SP_PERSP3D_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_PERSP3D, Persp3DClass))
18 #define SP_IS_PERSP3D(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_PERSP3D))
19 #define SP_IS_PERSP3D_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_PERSP3D))
21 #include <set>
22 #include <vector>
23 #include "sp-item.h"
24 #include "transf_mat_3x4.h"
26 class SPDocument;
27 class SPBox3D;
28 class Box3DContext;
30 struct Persp3D : public SPObject {
31     Proj::TransfMat3x4 tmat;
33     // TODO: Also write the list of boxes into the xml repr and vice versa link boxes to their persp3d?
34     std::vector<SPBox3D *> boxes;
35     SPDocument *document; // FIXME: should this rather be the SPDesktop?
37     // for debugging only
38     int my_counter;
39 };
41 struct Persp3DClass {
42     SPItemClass parent_class;
43 };
46 /* Standard GType function */
47 GType persp3d_get_type (void);
49 // FIXME: Make more of these inline!
50 inline Proj::Pt2 persp3d_get_VP (Persp3D *persp, Proj::Axis axis) { return persp->tmat.column(axis); }
51 NR::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, NR::Point const &pt, Proj::Axis axis); // convenience wrapper around the following two
52 NR::Point persp3d_get_finite_dir (Persp3D *persp, NR::Point const &pt, Proj::Axis axis);
53 NR::Point persp3d_get_infinite_dir (Persp3D *persp, Proj::Axis axis);
54 double persp3d_get_infinite_angle (Persp3D *persp, Proj::Axis axis);
55 bool persp3d_VP_is_finite (Persp3D *persp, Proj::Axis axis);
56 void persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo = true);
57 void persp3d_toggle_VPs (std::set<Persp3D *>, Proj::Axis axis);
58 void persp3d_set_VP_state (Persp3D *persp, Proj::Axis axis, Proj::VPState state);
59 void persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_pressed); // angle is in degrees
60 void persp3d_update_with_point (Persp3D *persp, Proj::Axis const axis, Proj::Pt2 const &new_image);
61 void persp3d_apply_affine_transformation (Persp3D *persp, NR::Matrix const &xform);
62 gchar * persp3d_pt_to_str (Persp3D *persp, Proj::Axis const axis);
64 void persp3d_add_box (Persp3D *persp, SPBox3D *box);
65 void persp3d_remove_box (Persp3D *persp, SPBox3D *box);
66 bool persp3d_has_box (Persp3D *persp, SPBox3D *box);
67 void persp3d_update_box_displays (Persp3D *persp);
68 void persp3d_update_box_reprs (Persp3D *persp);
69 void persp3d_update_z_orders (Persp3D *persp);
70 inline unsigned int persp3d_num_boxes (Persp3D *persp) { return persp->boxes.size(); }
71 std::list<SPBox3D *> persp3d_list_of_boxes(Persp3D *persp);
73 bool persp3d_perspectives_coincide(const Persp3D *lhs, const Persp3D *rhs);
74 void persp3d_absorb(Persp3D *persp1, Persp3D *persp2);
76 Persp3D * persp3d_create_xml_element (SPDocument *document, Persp3D *dup = NULL);
78 std::set<Persp3D *> persp3d_currently_selected_persps (SPEventContext *ec);
79 bool persp3d_has_all_boxes_in_selection (Persp3D *persp);
80 std::list<SPBox3D *> persp3d_selected_boxes (Persp3D *persp);
82 void persp3d_print_debugging_info (Persp3D *persp);
83 void persp3d_print_debugging_info_all(SPDocument *doc);
85 #endif /* __PERSP3D_H__ */
87 /*
88   Local Variables:
89   mode:c++
90   c-file-style:"stroustrup"
91   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
92   indent-tabs-mode:nil
93   fill-column:99
94   End:
95 */
96 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :