Code

Fix change in revision 9947 to be consistent with rest of the codebase.
[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 <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 class Persp3DImpl {
33 public:
34     Persp3DImpl();
36 //private:
37     Proj::TransfMat3x4 tmat;
39     // Also write the list of boxes into the xml repr and vice versa link boxes to their persp3d?
40     std::vector<SPBox3D *> boxes;
41     SPDocument *document;
43     // for debugging only
44     int my_counter;
46 //    friend class Persp3D;
47 };
49 struct Persp3D : public SPObject {
50     Persp3DImpl *perspective_impl;
51 };
53 struct Persp3DClass {
54     SPItemClass parent_class;
55 };
58 /* Standard GType function */
59 GType persp3d_get_type (void);
61 // FIXME: Make more of these inline!
62 inline Persp3D * persp3d_get_from_repr (Inkscape::XML::Node *repr) {
63     return SP_PERSP3D(SP_ACTIVE_DOCUMENT->getObjectByRepr(repr));
64 }
65 inline Proj::Pt2 persp3d_get_VP (Persp3D *persp, Proj::Axis axis) {
66     return persp->perspective_impl->tmat.column(axis);
67 }
68 Geom::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis); // convenience wrapper around the following two
69 Geom::Point persp3d_get_finite_dir (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis);
70 Geom::Point persp3d_get_infinite_dir (Persp3D *persp, Proj::Axis axis);
71 double persp3d_get_infinite_angle (Persp3D *persp, Proj::Axis axis);
72 bool persp3d_VP_is_finite (Persp3DImpl *persp_impl, Proj::Axis axis);
73 void persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo = true);
74 void persp3d_toggle_VPs (std::list<Persp3D *>, Proj::Axis axis);
75 void persp3d_set_VP_state (Persp3D *persp, Proj::Axis axis, Proj::VPState state);
76 void persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_pressed); // angle is in degrees
77 void persp3d_apply_affine_transformation (Persp3D *persp, Geom::Matrix const &xform);
79 void persp3d_add_box (Persp3D *persp, SPBox3D *box);
80 void persp3d_remove_box (Persp3D *persp, SPBox3D *box);
81 bool persp3d_has_box (Persp3D *persp, SPBox3D *box);
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->perspective_impl->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, Persp3DImpl *dup = NULL);
93 Persp3D * persp3d_document_first_persp (SPDocument *document);
95 bool persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::Selection *selection);
97 void persp3d_print_debugging_info (Persp3D *persp);
98 void persp3d_print_debugging_info_all(SPDocument *doc);
99 void persp3d_print_all_selected();
101 void print_current_persp3d(gchar *func_name, Persp3D *persp);
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:fileencoding=utf-8:textwidth=99 :