From 30493d6d028485e65dd0fb61ea9978c7b128e817 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Sun, 13 Jan 2008 18:17:32 +0000 Subject: Use visual/geometric bbox (as specified in Selector tool preferences) when converting to guidelines. Also, provide options to convert rectangles and 3D boxes using their bbox, too (i.e., disregarding their true shapes). (bzr r4477) --- src/box3d.cpp | 6 ++++++ src/sp-item.cpp | 12 ++++++++++-- src/sp-rect.cpp | 6 ++++++ src/ui/dialog/inkscape-preferences.cpp | 8 ++++++++ src/ui/dialog/inkscape-preferences.h | 1 + 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/box3d.cpp b/src/box3d.cpp index 631d5cfc1..3c40a4800 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" @@ -1496,6 +1497,11 @@ box3d_push_back_corner_pair(SPBox3D *box, std::list @@ -1579,9 +1581,15 @@ sp_item_first_item_child (SPObject *obj) void sp_item_convert_to_guides(SPItem *item) { - NR::Maybe bbox = sp_item_bbox_desktop(item, SPItem::GEOMETRIC_BBOX); + SPDesktop *dt = inkscape_active_desktop(); + SPNamedView *nv = sp_desktop_namedview(dt); + + gchar const *prefs_bbox = prefs_get_string_attribute("tools.select", "bounding_box"); + SPItem::BBoxType bbox_type = (prefs_bbox != NULL && strcmp(prefs_bbox, "geometric")==0)? SPItem::GEOMETRIC_BBOX : SPItem::RENDERING_BBOX; + + NR::Maybe bbox = sp_item_bbox_desktop(item, bbox_type); if (!bbox) { - g_print ("Cannot determine bounding box. Doing nothing.\n"); + g_warning ("Cannot determine item's bounding box during conversion to guides.\n"); return; } diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index e8e04cc51..5770e623d 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -29,6 +29,7 @@ #include #include "xml/repr.h" #include "sp-guide.h" +#include "prefs-utils.h" #define noRECT_VERBOSE @@ -581,6 +582,11 @@ static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p) void sp_rect_convert_to_guides(SPRect *rect, bool write_undo) { + if (prefs_get_int_attribute("tools.shapes.rect", "convertguides", 1) == 0) { + sp_item_convert_to_guides(SP_ITEM(rect)); + return; + } + SPDocument *doc = SP_OBJECT_DOCUMENT(rect); std::list > pts; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index e88ba74b1..b07914265 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -229,6 +229,12 @@ void InkscapePreferences::AddGradientCheckbox(DialogPage& p, const std::string& p.add_line( false, "", *cb, "", _("Whether selected objects display gradient editing controls")); } +void InkscapePreferences::AddConvertGuidesCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value) { + PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); + cb->init ( _("Conversion to guides uses edges instead of bounding box"), prefs_path, "convertguides", def_value); + p.add_line( false, "", *cb, "", _("Converting an object to guides places these along the object's true edges (imitating the object's shape), not along the bounding box.")); +} + void StyleFromSelectionToTool(gchar const *prefs_path, StyleSwatch *swatch) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -374,9 +380,11 @@ void InkscapePreferences::initPageTools() //Rectangle this->AddPage(_page_rectangle, _("Rectangle"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_RECT); this->AddNewObjectsStyle(_page_rectangle, "tools.shapes.rect"); + this->AddConvertGuidesCheckbox(_page_rectangle, "tools.shapes.rect", true); //3D box this->AddPage(_page_3dbox, _("3D Box"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_3DBOX); this->AddNewObjectsStyle(_page_3dbox, "tools.shapes.3dbox"); + this->AddConvertGuidesCheckbox(_page_3dbox, "tools.shapes.3dbox", true); //ellipse this->AddPage(_page_ellipse, _("Ellipse"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_ELLIPSE); this->AddNewObjectsStyle(_page_ellipse, "tools.shapes.arc"); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index b0c47a8f0..fd340769e 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -215,6 +215,7 @@ protected: static void AddSelcueCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value); static void AddGradientCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value); + static void AddConvertGuidesCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value); static void AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path); void on_pagelist_selection_changed(); -- cgit v1.2.3