X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fbox3d.cpp;h=72aff25985fcb49d54a502074f6fa6b0225137d1;hb=f2c65c84b2e5016ef16907bf15d51ded9c25411e;hp=631d5cfc1d27be44ea582aaddfb4eb0344114fc5;hpb=32461c0cc717f51ba84908e1eea5b1ee150cf27e;p=inkscape.git diff --git a/src/box3d.cpp b/src/box3d.cpp index 631d5cfc1..72aff2598 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -34,6 +34,7 @@ #include "2geom/geom.h" #include "sp-guide.h" #include "sp-namedview.h" +#include "prefs-utils.h" #include "desktop.h" #include "macros.h" @@ -49,11 +50,10 @@ static Inkscape::XML::Node *box3d_write(SPObject *object, Inkscape::XML::Node *r static gchar *box3d_description(SPItem *item); static NR::Matrix box3d_set_transform(SPItem *item, NR::Matrix const &xform); +static void box3d_convert_to_guides(SPItem *item); static void box3d_ref_changed(SPObject *old_ref, SPObject *ref, SPBox3D *box); static void box3d_ref_modified(SPObject *href, guint flags, SPBox3D *box); -//static void box3d_ref_changed(SPObject *old_ref, SPObject *ref, Persp3D *persp); -//static void box3d_ref_modified(SPObject *href, guint flags, Persp3D *persp); static SPGroupClass *parent_class; @@ -99,6 +99,7 @@ box3d_class_init(SPBox3DClass *klass) item_class->description = box3d_description; item_class->set_transform = box3d_set_transform; + item_class->convert_to_guides = box3d_convert_to_guides; } static void @@ -615,6 +616,9 @@ box3d_set_corner (SPBox3D *box, const guint id, NR::Point const &new_pos, const void box3d_set_center (SPBox3D *box, NR::Point const &new_pos, NR::Point const &old_pos, const Box3D::Axis movement, bool constrained) { g_return_if_fail ((movement != Box3D::NONE) && (movement != Box3D::XYZ)); + box->orig_corner0.normalize(); + box->orig_corner7.normalize(); + Persp3D *persp = box3d_get_perspective(box); if (!(movement & Box3D::Z)) { double coord = (box->orig_corner0[Proj::Z] + box->orig_corner7[Proj::Z]) / 2; @@ -624,6 +628,7 @@ void box3d_set_center (SPBox3D *box, NR::Point const &new_pos, NR::Point const & Proj::Pt3 pt_proj (persp->tmat.preimage (new_pos, coord, Proj::Z)); if (constrained) { Proj::Pt3 old_pos_proj (persp->tmat.preimage (old_pos, coord, Proj::Z)); + old_pos_proj.normalize(); pt_proj = box3d_snap (box, -1, pt_proj, old_pos_proj); } // normalizing pt_proj is essential because we want to mingle affine coordinates @@ -991,7 +996,11 @@ box3d_set_new_z_orders_case2 (SPBox3D *box, int z_orders[6], Box3D::Axis central box3d_aux_set_z_orders (z_orders, 3, 1, 5, 2, 4, 0); } else { //g_print ("central axis X (case b3)"); - box3d_aux_set_z_orders (z_orders, 3, 1, 5, 0, 2, 4); + if (insidexy == 0) { + box3d_aux_set_z_orders (z_orders, 3, 5, 1, 0, 2, 4); + } else { + box3d_aux_set_z_orders (z_orders, 3, 1, 5, 0, 2, 4); + } } } } @@ -1007,7 +1016,11 @@ box3d_set_new_z_orders_case2 (SPBox3D *box, int z_orders[6], Box3D::Axis central } } else { //g_print ("central axis Y (case b)"); - box3d_aux_set_z_orders (z_orders, 5, 0, 4, 1, 3, 2); + if (insideyx == 1) { + box3d_aux_set_z_orders (z_orders, 4, 0, 5, 1, 3, 2); + } else { + box3d_aux_set_z_orders (z_orders, 5, 0, 4, 1, 3, 2); + } } break; case Box3D::Z: @@ -1488,17 +1501,22 @@ box3d_convert_to_group(SPBox3D *box) { return SP_GROUP(doc->getObjectByRepr(grepr)); } -static void +static inline void box3d_push_back_corner_pair(SPBox3D *box, std::list > &pts, int c1, int c2) { pts.push_back(std::make_pair(box3d_get_corner_screen(box, c1).to_2geom(), box3d_get_corner_screen(box, c2).to_2geom())); } void -box3d_convert_to_guides(SPBox3D *box, bool write_undo) { +box3d_convert_to_guides(SPItem *item) { + SPBox3D *box = SP_BOX3D(item); + + if (prefs_get_int_attribute("tools.shapes.3dbox", "convertguides", 1) == 0) { + sp_item_convert_to_guides(SP_ITEM(box)); + return; + } + SPDocument *doc = SP_OBJECT_DOCUMENT(box); - //SPDesktop *desktop = inkscape_active_desktop(); - //Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); std::list > pts; @@ -1521,12 +1539,6 @@ box3d_convert_to_guides(SPBox3D *box, bool write_undo) { box3d_push_back_corner_pair(box, pts, 3, 7); sp_guide_pt_pairs_to_guides(doc, pts); - - SP_OBJECT(box)->deleteObject(true); - - if (write_undo) { - sp_document_done(doc, SP_VERB_CONTEXT_3DBOX, _("Convert to guides")); - } } /*