diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2007-09-10 21:15:56 +0000 |
|---|---|---|
| committer | dvlierop2 <dvlierop2@users.sourceforge.net> | 2007-09-10 21:15:56 +0000 |
| commit | 9ed337ebdfeff1528af7efb8fb0973170ed68200 (patch) | |
| tree | cf036b9761f6ffeb6a6a1a622871ce0288438bc8 /src/object-snapper.cpp | |
| parent | add missed paint type assignment, fixes crash with no fill/no stroke on selec... (diff) | |
| download | inkscape-9ed337ebdfeff1528af7efb8fb0973170ed68200.tar.gz inkscape-9ed337ebdfeff1528af7efb8fb0973170ed68200.zip | |
Inkscape becomes unusable when trying to snap to the path of a traced bitmap or a text paragraph. Make it usable again by not snapping to text longer than 240 chars or paths containing more than 500 nodes. Snapping to more than one of such objects will still be very slow.
(bzr r3716)
Diffstat (limited to 'src/object-snapper.cpp')
| -rw-r--r-- | src/object-snapper.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 960d4f115..ab222f286 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -22,7 +22,9 @@ #include "desktop.h" #include "inkscape.h" #include "prefs-utils.h" - +#include "sp-text.h" +#include "sp-flowtext.h" +#include "text-editing.h" Inkscape::ObjectSnapper::ObjectSnapper(SPNamedView const *nv, NR::Coord const d) : Snapper(nv, d), _snap_to_itemnode(true), _snap_to_itempath(true), @@ -80,7 +82,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* r, i++; } - if (i == it.end()) { + if (i == it.end()) { /* See if the item is within range */ if (SP_IS_GROUP(o)) { _findCandidates(o, it, false, points_to_snap, snap_dim); @@ -269,7 +271,29 @@ void Inkscape::ObjectSnapper::_snapPaths(Inkscape::Snapper::PointType const &t, //Add the item's path to snap to if (_snap_to_itempath) { if (!(_strict_snapping && !p_is_a_node)) { - _paths_to_snap_to->push_back(Path_for_item(root_item, true, true)); + // Snapping to the path of characters is very cool, but for a large + // chunk of text this will take ages! So limit snapping to text paths + // containing max. 240 characters. Snapping the bbox will not be affected + bool very_lenghty_prose = false; + if (SP_IS_TEXT(root_item) || SP_IS_FLOWTEXT(root_item)) { + very_lenghty_prose = sp_text_get_length(SP_TEXT(root_item)) > 240; + } + + // On my AMD 3000+, the snapping lag becomes annoying at approx. 240 chars + // which corresponds to a lag of 500 msec. This is for snapping a rect + // to a single line of text. + + // Snapping for example to a traced bitmap is also very stressing for + // the CPU, so we'll only snap to paths having no more than 500 nodes + // This also leads to a lag of approx. 500 msec (in my lousy test set-up). + bool very_complex_path = false; + if (SP_IS_PATH(root_item)) { + very_complex_path = sp_nodes_in_path(SP_PATH(root_item)) > 500; + } + + if (!very_lenghty_prose && !very_complex_path) { + _paths_to_snap_to->push_back(Path_for_item(root_item, true, true)); + } } } |
