diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2007-12-13 09:45:27 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2007-12-13 09:45:27 +0000 |
| commit | cae2409c94b11d17643f7c19829e2653d759ff8e (patch) | |
| tree | a8399ab9b3e8ff2570a92bef06e63f2307fef592 /src/box3d.h | |
| parent | libgdl: avoid setting a negative preferred height for dock items, (diff) | |
| download | inkscape-cae2409c94b11d17643f7c19829e2653d759ff8e.tar.gz inkscape-cae2409c94b11d17643f7c19829e2653d759ff8e.zip | |
Fundamentally reworked version of the 3D box tool (among many other things, this fixes bugs #168900 and #168868). See mailing list for details. Sorry for this single large commit but it was unfeasible to keep the history.
(bzr r4224)
Diffstat (limited to 'src/box3d.h')
| -rw-r--r-- | src/box3d.h | 131 |
1 files changed, 56 insertions, 75 deletions
diff --git a/src/box3d.h b/src/box3d.h index 1e567ded9..c676696e9 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -1,5 +1,5 @@ -#ifndef __SP_3DBOX_H__ -#define __SP_3DBOX_H__ +#ifndef __SP_BOX3D_H__ +#define __SP_BOX3D_H__ /* * SVG <box3d> implementation @@ -15,90 +15,71 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "inkscape.h" -#include "perspective-line.h" - #include "sp-item-group.h" -#include "sp-path.h" -#include "xml/document.h" -#include "xml/repr.h" -#include "line-geometry.h" -#include "box3d-face.h" - +#include "proj_pt.h" +#include "axis-manip.h" -#define SP_TYPE_3DBOX (sp_3dbox_get_type ()) -#define SP_3DBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_3DBOX, SP3DBox)) -#define SP_3DBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_3DBOX, SP3DBoxClass)) -#define SP_IS_3DBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_3DBOX)) -#define SP_IS_3DBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_3DBOX)) +#define SP_TYPE_BOX3D (box3d_get_type ()) +#define SP_BOX3D(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_BOX3D, SPBox3D)) +#define SP_BOX3D_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_BOX3D, Box3DClass)) +#define SP_IS_BOX3D(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_BOX3D)) +#define SP_IS_BOX3D_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_BOX3D)) +class Box3DSide; +class Persp3D; +class Persp3DReference; -struct SP3DBox : public SPGroup { - NR::Point corners[8]; - Box3DFace *faces[6]; +struct SPBox3D : public SPGroup { gint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom) - std::vector<gint> currently_visible_faces; + gchar *persp_href; + Persp3DReference *persp_ref; - // TODO: Keeping/updating the ratios works reasonably well but is still an ad hoc implementation. - // Use a mathematically correct model to update the boxes. - double ratio_x; - double ratio_y; - double ratio_z; + sigc::connection modified_connection; - guint front_bits; /* used internally to determine which of two parallel faces is supposed to be the front face */ + Proj::Pt3 orig_corner0; + Proj::Pt3 orig_corner7; - // FIXME: If we only allow a single box to be dragged at a time then we can save memory by storing - // the old positions centrally in SP3DBoxContext (instead of in each box separately) - // Also, it may be better not to store the old corners but rather the old lines to which we want to snap - NR::Point old_center; - NR::Point old_corner2; - NR::Point old_corner1; - NR::Point old_corner0; - NR::Point old_corner3; - NR::Point old_corner5; - NR::Point old_corner7; + Proj::Pt3 save_corner0; + Proj::Pt3 save_corner7; - gint my_counter; // for testing only + gint my_counter; // for debugging only }; -struct SP3DBoxClass { - SPGroupClass parent_class; +struct SPBox3DClass { + SPGroupClass parent_class; }; -GType sp_3dbox_get_type (void); - -void sp_3dbox_position_set (SP3DBoxContext &bc); -void sp_3dbox_set_shape(SP3DBox *box3d, bool use_previous_corners = false); -void sp_3dbox_recompute_corners (SP3DBox *box, NR::Point const pt1, NR::Point const pt2, NR::Point const pt3); -void sp_3dbox_set_z_orders_in_the_first_place (SP3DBox *box); -void sp_3dbox_set_z_orders_later_on (SP3DBox *box); -void sp_3dbox_update_curves (SP3DBox *box); -void sp_3dbox_link_to_existing_paths (SP3DBox *box, Inkscape::XML::Node *repr); -void sp_3dbox_set_ratios (SP3DBox *box, Box3D::Axis axes = Box3D::XYZ); -void sp_3dbox_switch_front_face (SP3DBox *box, Box3D::Axis axis); -void sp_3dbox_reshape_after_VP_rotation (SP3DBox *box, Box3D::Axis axis); -void sp_3dbox_move_corner_in_XY_plane (SP3DBox *box, guint id, NR::Point pt, Box3D::Axis axes = Box3D::XY); -void sp_3dbox_move_corner_in_Z_direction (SP3DBox *box, guint id, NR::Point pt, bool constrained = true); -void sp_3dbox_reshape_after_VP_toggling (SP3DBox *box, Box3D::Axis axis); -NR::Maybe<NR::Point> sp_3dbox_get_center (SP3DBox *box); -NR::Maybe<NR::Point> sp_3dbox_get_midpoint_between_corners (SP3DBox *box, guint id_corner1, guint id_corner2); -void sp_3dbox_recompute_XY_corners_from_new_center (SP3DBox *box, NR::Point const new_center); -void sp_3dbox_recompute_Z_corners_from_new_center (SP3DBox *box, NR::Point const new_center); -NR::Point sp_3dbox_get_midpoint_in_axis_direction (NR::Point const &C, NR::Point const &D, Box3D::Axis axis, Box3D::Perspective3D *persp); - -void sp_3dbox_update_perspective_lines(); -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); -guint sp_3dbox_get_corner_id_along_edge (const SP3DBox *box, guint corner, Box3D::Axis axis, Box3D::FrontOrRear rel_pos); -NR::Point sp_3dbox_get_corner_along_edge (const SP3DBox *box, guint corner, Box3D::Axis axis, Box3D::FrontOrRear rel_pos); -guint sp_3dbox_get_front_corner_id (const SP3DBox *box); - - -gchar * sp_3dbox_get_svg_descr_of_persp (Box3D::Perspective3D *persp); - -inline NR::Point sp_3dbox_get_corner (SP3DBox *box, guint id) { return box->corners[id]; } -inline bool sp_3dbox_corners_are_adjacent (guint id_corner1, guint id_corner2) { - return Box3D::is_single_axis_direction ((Box3D::Axis) (id_corner1 ^ id_corner2)); -} - -#endif +GType box3d_get_type (void); + +void box3d_position_set (SPBox3D *box); +Proj::Pt3 box3d_get_proj_corner (SPBox3D const *box, guint id); +NR::Point box3d_get_corner_screen (SPBox3D const *box, guint id); +Proj::Pt3 box3d_get_proj_center (SPBox3D *box); +NR::Point box3d_get_center_screen (SPBox3D *box); + +void box3d_set_corner (SPBox3D *box, guint id, NR::Point const &new_pos, Box3D::Axis movement, bool constrained); +void box3d_set_center (SPBox3D *box, NR::Point const &new_pos, NR::Point const &old_pos, Box3D::Axis movement, bool constrained); +void box3d_corners_for_PLs (const SPBox3D * box, Proj::Axis axis, NR::Point &corner1, NR::Point &corner2, NR::Point &corner3, NR::Point &corner4); +bool box3d_recompute_z_orders (SPBox3D *box); +void box3d_set_z_orders (SPBox3D *box); + +int box3d_pt_lies_in_PL_sector (SPBox3D const *box, NR::Point const &pt, int id1, int id2, Box3D::Axis axis); +int box3d_VP_lies_in_PL_sector (SPBox3D const *box, Proj::Axis vpdir, int id1, int id2, Box3D::Axis axis); + +/* ensures that the coordinates of corner0 and corner7 are in the correct order (to prevent everted boxes) */ +void box3d_relabel_corners(SPBox3D *box); + + +#endif /* __SP_BOX3D_H__ */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : |
