diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-07-07 14:06:53 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-07-07 14:06:53 +0000 |
| commit | edc1ce81eba1b06764310977a81e7fff9e89727d (patch) | |
| tree | a3c352bf8c7c8f1400b5d3e1f80cd849b2a19bd0 /src/sp-shape.cpp | |
| parent | remove dead code (diff) | |
| download | inkscape-edc1ce81eba1b06764310977a81e7fff9e89727d.tar.gz inkscape-edc1ce81eba1b06764310977a81e7fff9e89727d.zip | |
fix number of marker counting in shape
(bzr r6208)
Diffstat (limited to 'src/sp-shape.cpp')
| -rw-r--r-- | src/sp-shape.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index e38dba48f..308b5a1ba 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -799,20 +799,44 @@ sp_shape_has_markers (SPShape const *shape) int sp_shape_number_of_markers (SPShape *shape, int type) { -// TODO fixme: this looks very bad that the type parameter is ignored. Geom::PathVector const & pathv = shape->curve->get_pathvector(); - guint n = shape->marker[SP_MARKER_LOC_START] ? pathv.size() : 0; + switch(type) { + case SP_MARKER_LOC_START: + return shape->marker[SP_MARKER_LOC_START] ? pathv.size() : 0; - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - n += shape->marker[SP_MARKER_LOC_MID] ? path_it->size() : 0; + case SP_MARKER_LOC_MID: + { + if ( shape->marker[SP_MARKER_LOC_MID] ) { + guint n = 0; + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { + n += path_it->size(); + n += path_it->closed() ? 1 : 0; + } + return n; + } else { + return 0; + } + } - if ( shape->marker[SP_MARKER_LOC_END] && !path_it->empty()) { - n++; + case SP_MARKER_LOC_END: + { + if ( shape->marker[SP_MARKER_LOC_END] ) { + guint n = 0; + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { + if (!path_it->empty()) { + n++; + } + } + return n; + } else { + return 0; + } } - } - return n; + default: + return 0; + } } /** |
