Code

Fix behaviour of toggle buttons (for VP states) in 3D box toolbar; reshape boxes...
[inkscape.git] / src / box3d.h
1 #ifndef __SP_3DBOX_H__
2 #define __SP_3DBOX_H__
4 /*
5  * SVG <box3d> implementation
6  *
7  * Authors:
8  *   Lauris Kaplinski <lauris@kaplinski.com>
9  *   Maximilian Albert <Anhalter42@gmx.de>
10  *
11  * Copyright (C) 2007      Authors
12  * Copyright (C) 1999-2002 Lauris Kaplinski
13  * Copyright (C) 2000-2001 Ximian, Inc.
14  *
15  * Released under GNU GPL, read the file 'COPYING' for more information
16  */
18 #include "inkscape.h"
19 #include "perspective-line.h"
21 #include "sp-item-group.h"
22 #include "sp-path.h"
23 #include "xml/document.h"
24 #include "xml/repr.h"
25 #include "line-geometry.h"
26 #include "box3d-face.h"
29 #define SP_TYPE_3DBOX            (sp_3dbox_get_type ())
30 #define SP_3DBOX(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_3DBOX, SP3DBox))
31 #define SP_3DBOX_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_3DBOX, SP3DBoxClass))
32 #define SP_IS_3DBOX(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_3DBOX))
33 #define SP_IS_3DBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_3DBOX))
36 struct SP3DBox : public SPGroup {
37     NR::Point corners[8];
38     Box3DFace *faces[6];
39     guint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom)
41     // TODO: Keeping/updating the ratios works reasonably well but is still an ad hoc implementation.
42     //       Use a mathematically correct model to update the boxes.
43     double ratio_x;
44     double ratio_y;
45     double ratio_z;
47     guint front_bits; /* used internally to determine which of two parallel faces is supposed to be the front face */
49     gint my_counter; // for testing only
50 };
52 struct SP3DBoxClass {
53         SPGroupClass parent_class;
54 };
56 GType sp_3dbox_get_type (void);
58 void sp_3dbox_position_set (SP3DBoxContext &bc);
59 void sp_3dbox_set_shape(SP3DBox *box3d, bool use_previous_corners = false);
60 void sp_3dbox_recompute_corners (SP3DBox *box, NR::Point const pt1, NR::Point const pt2, NR::Point const pt3);
61 bool sp_3dbox_recompute_z_orders (SP3DBox *box); /* returns true if there was a change in the z-orders
62                                                     (which triggers an update of the repr) */
63 void sp_3dbox_set_z_orders (SP3DBox *box);
64 void sp_3dbox_update_curves (SP3DBox *box);
65 void sp_3dbox_link_to_existing_paths (SP3DBox *box, Inkscape::XML::Node *repr);
66 void sp_3dbox_set_ratios (SP3DBox *box, Box3D::Axis axes = Box3D::XYZ);
67 void sp_3dbox_switch_front_face (SP3DBox *box, Box3D::Axis axis);
68 void sp_3dbox_move_corner_in_XY_plane (SP3DBox *box, guint id, NR::Point pt, Box3D::Axis axes = Box3D::XY);
69 void sp_3dbox_move_corner_in_Z_direction (SP3DBox *box, guint id, NR::Point pt, bool constrained = true);
70 void sp_3dbox_reshape_after_VP_toggling (SP3DBox *box, Box3D::Axis axis);
71 NR::Maybe<NR::Point> sp_3dbox_get_center (SP3DBox *box);
72 NR::Maybe<NR::Point> sp_3dbox_get_midpoint_between_corners (SP3DBox *box, guint id_corner1, guint id_corner2);
74 void sp_3dbox_update_perspective_lines();
75 void sp_3dbox_corners_for_perspective_lines (const SP3DBox * box, Box3D::Axis axis, NR::Point &corner1, NR::Point &corner2, NR::Point &corner3, NR::Point &corner4);
76 guint sp_3dbox_get_corner_id_along_edge (const SP3DBox *box, guint corner, Box3D::Axis axis, Box3D::FrontOrRear rel_pos);
77 NR::Point sp_3dbox_get_corner_along_edge (const SP3DBox *box, guint corner, Box3D::Axis axis, Box3D::FrontOrRear rel_pos);
78 guint sp_3dbox_get_front_corner_id (const SP3DBox *box);
81 gchar * sp_3dbox_get_svg_descr_of_persp (Box3D::Perspective3D *persp);
83 inline NR::Point sp_3dbox_get_corner (SP3DBox *box, guint id) { return box->corners[id]; }
84 inline bool sp_3dbox_corners_are_adjacent (guint id_corner1, guint id_corner2) {
85   return Box3D::is_single_axis_direction ((Box3D::Axis) (id_corner1 ^ id_corner2));
86 }
88 #endif