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 <list>
22 #include <vector>
23 #include <map>
24 #include "sp-item.h"
25 #include "transf_mat_3x4.h"
26 #include "document.h"
27 #include "inkscape.h"
29 class SPBox3D;
30 class Box3DContext;
32 struct Persp3D : public SPObject {
33 Proj::TransfMat3x4 tmat;
35 // Also write the list of boxes into the xml repr and vice versa link boxes to their persp3d?
36 std::vector<SPBox3D *> boxes;
37 std::map<SPBox3D *, bool>* boxes_transformed; // TODO: eventually we should merge this with 'boxes'
38 SPDocument *document; // should this rather be the SPDesktop?
40 // for debugging only
41 int my_counter;
42 };
44 struct Persp3DClass {
45 SPItemClass parent_class;
46 };
49 /* Standard GType function */
50 GType persp3d_get_type (void);
52 // FIXME: Make more of these inline!
53 inline Persp3D * persp3d_get_from_repr (Inkscape::XML::Node *repr) {
54 return SP_PERSP3D(SP_ACTIVE_DOCUMENT->getObjectByRepr(repr));
55 }
56 inline Proj::Pt2 persp3d_get_VP (Persp3D *persp, Proj::Axis axis) {
57 return persp->tmat.column(axis);
58 }
59 Geom::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis); // convenience wrapper around the following two
60 Geom::Point persp3d_get_finite_dir (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis);
61 Geom::Point persp3d_get_infinite_dir (Persp3D *persp, Proj::Axis axis);
62 double persp3d_get_infinite_angle (Persp3D *persp, Proj::Axis axis);
63 bool persp3d_VP_is_finite (Persp3D *persp, Proj::Axis axis);
64 void persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo = true);
65 void persp3d_toggle_VPs (std::list<Persp3D *>, Proj::Axis axis);
66 void persp3d_set_VP_state (Persp3D *persp, Proj::Axis axis, Proj::VPState state);
67 void persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_pressed); // angle is in degrees
68 void persp3d_update_with_point (Persp3D *persp, Proj::Axis const axis, Proj::Pt2 const &new_image);
69 void persp3d_apply_affine_transformation (Persp3D *persp, Geom::Matrix const &xform);
70 gchar * persp3d_pt_to_str (Persp3D *persp, Proj::Axis const axis);
72 void persp3d_add_box (Persp3D *persp, SPBox3D *box);
73 void persp3d_remove_box (Persp3D *persp, SPBox3D *box);
74 bool persp3d_has_box (Persp3D *persp, SPBox3D *box);
76 void persp3d_add_box_transform (Persp3D *persp, SPBox3D *box);
77 void persp3d_remove_box_transform (Persp3D *persp, SPBox3D *box);
78 void persp3d_set_box_transformed (Persp3D *persp, SPBox3D *box, bool transformed = true);
79 bool persp3d_was_transformed (Persp3D *persp);
80 bool persp3d_all_transformed(Persp3D *persp);
81 void persp3d_unset_transforms(Persp3D *persp);
83 void persp3d_update_box_displays (Persp3D *persp);
84 void persp3d_update_box_reprs (Persp3D *persp);
85 void persp3d_update_z_orders (Persp3D *persp);
86 inline unsigned int persp3d_num_boxes (Persp3D *persp) { return persp->boxes.size(); }
87 std::list<SPBox3D *> persp3d_list_of_boxes(Persp3D *persp);
89 bool persp3d_perspectives_coincide(const Persp3D *lhs, const Persp3D *rhs);
90 void persp3d_absorb(Persp3D *persp1, Persp3D *persp2);
92 Persp3D * persp3d_create_xml_element (SPDocument *document, Persp3D *dup = NULL);
93 Persp3D * persp3d_document_first_persp (SPDocument *document);
95 bool persp3d_has_all_boxes_in_selection (Persp3D *persp);
96 std::map<Persp3D *, std::list<SPBox3D *> > persp3d_unselected_boxes(Inkscape::Selection *selection);
97 void persp3d_split_perspectives_according_to_selection(Inkscape::Selection *selection);
99 void persp3d_print_debugging_info (Persp3D *persp);
100 void persp3d_print_debugging_info_all(SPDocument *doc);
101 void persp3d_print_all_selected();
103 #endif /* __PERSP3D_H__ */
105 /*
106 Local Variables:
107 mode:c++
108 c-file-style:"stroustrup"
109 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
110 indent-tabs-mode:nil
111 fill-column:99
112 End:
113 */
114 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :