Index: src/extension/internal/cairo-renderer.cpp =================================================================== --- src/extension/internal/cairo-renderer.cpp (revision 22518) +++ src/extension/internal/cairo-renderer.cpp (working copy) @@ -192,22 +192,21 @@ ctx->renderPathVector(pathv, style, &pbox); - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - // START position - for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START - if ( shape->marker[i] ) { - SPMarker* marker = SP_MARKER (shape->marker[i]); - Geom::Matrix tr; - if (marker->orient_auto) { - tr = sp_shape_marker_get_transform_at_start(path_it->front()); - } else { - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(path_it->front().pointAt(0)); - } - sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx); + // START position + for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START + if ( shape->marker[i] ) { + SPMarker* marker = SP_MARKER (shape->marker[i]); + Geom::Matrix tr; + if (marker->orient_auto) { + tr = sp_shape_marker_get_transform_at_start(pathv.begin()->front()); + } else { + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(pathv.begin()->front().pointAt(0)); } + sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx); } - - // MID position + } + // MID position + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { for (int i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID if ( shape->marker[i] && (path_it->size_default() > 1) ) { Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve @@ -234,29 +233,29 @@ } } } + } + // END position + for (int i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END + if ( shape->marker[i] ) { + SPMarker* marker = SP_MARKER (shape->marker[i]); - // END position - for (int i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END - if ( shape->marker[i] ) { - SPMarker* marker = SP_MARKER (shape->marker[i]); + /* Get reference to last curve in the path. + * For moveto-only path, this returns the "closing line segment". */ + Geom::Path const &path_last = pathv.back(); + unsigned int index = path_last.size_default(); + if (index > 0) { + index--; + } + Geom::Curve const &lastcurve = path_last[index]; - /* Get reference to last curve in the path. - * For moveto-only path, this returns the "closing line segment". */ - unsigned int index = path_it->size_default(); - if (index > 0) { - index--; - } - Geom::Curve const &lastcurve = (*path_it)[index]; - - Geom::Matrix tr; - if (marker->orient_auto) { - tr = sp_shape_marker_get_transform_at_end(lastcurve); - } else { - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(lastcurve.pointAt(1)); - } - - sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx); + Geom::Matrix tr; + if (marker->orient_auto) { + tr = sp_shape_marker_get_transform_at_end(lastcurve); + } else { + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(lastcurve.pointAt(1)); } + + sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx); } } } Index: src/sp-shape.cpp =================================================================== --- src/sp-shape.cpp (revision 22518) +++ src/sp-shape.cpp (working copy) @@ -409,9 +409,10 @@ int counter[4] = {0}; Geom::PathVector const & pathv = shape->curve->get_pathvector(); - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - // START position - Geom::Matrix const m (sp_shape_marker_get_transform_at_start(path_it->front())); + + // START position + { + Geom::Matrix const m (sp_shape_marker_get_transform_at_start(pathv.begin()->front())); for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START if ( shape->marker[i] ) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, @@ -420,8 +421,10 @@ counter[i]++; } } + } - // MID position + // MID position + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { if ( (shape->marker[SP_MARKER_LOC_MID] || shape->marker[SP_MARKER_LOC]) && (path_it->size_default() > 1) ) { Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve @@ -445,26 +448,26 @@ ++curve_it2; } } + } + // END position + if ( shape->marker[SP_MARKER_LOC_END] || shape->marker[SP_MARKER_LOC] ) { + /* Get reference to last curve in the path. + * For moveto-only path, this returns the "closing line segment". */ + Geom::Path const &path_last = pathv.back(); + unsigned int index = path_last.size_default(); + if (index > 0) { + index--; + } + Geom::Curve const &lastcurve = path_last[index]; + Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve); - // END position - if ( shape->marker[SP_MARKER_LOC_END] || shape->marker[SP_MARKER_LOC] ) { - /* Get reference to last curve in the path. - * For moveto-only path, this returns the "closing line segment". */ - unsigned int index = path_it->size_default(); - if (index > 0) { - index--; + for (int i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END + if (shape->marker[i]) { + sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, + NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + style->stroke_width.computed); + counter[i]++; } - Geom::Curve const &lastcurve = (*path_it)[index]; - Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve); - - for (int i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END - if (shape->marker[i]) { - sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, - style->stroke_width.computed); - counter[i]++; - } - } } } } @@ -522,36 +525,37 @@ // Union with bboxes of the markers, if any if (sp_shape_has_markers (shape)) { - /* TODO: make code prettier: lots of variables can be taken out of the loop! */ + /** \todo make code prettier! */ Geom::PathVector const & pathv = shape->curve->get_pathvector(); - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START - if ( shape->marker[i] ) { - SPMarker* marker = SP_MARKER (shape->marker[i]); - SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker)); + // START marker + for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START + if ( shape->marker[i] ) { + SPMarker* marker = SP_MARKER (shape->marker[i]); + SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker)); - if (marker_item) { - Geom::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front())); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } + if (marker_item) { + Geom::Matrix tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front())); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; + } - // total marker transform - tr = marker_item->transform * marker->c2p * tr * transform; + // total marker transform + tr = marker_item->transform * marker->c2p * tr * transform; - // get bbox of the marker with that transform - NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); - // union it with the shape bbox - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } + // get bbox of the marker with that transform + NRRect marker_bbox; + sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + // union it with the shape bbox + nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } } - + } + // MID marker + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID if ( shape->marker[i] && (path_it->size_default() > 1) ) { Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve @@ -590,39 +594,40 @@ } } } + } + // END marker + for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END + if ( shape->marker[i] ) { + SPMarker* marker = SP_MARKER (shape->marker[i]); + SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker)); - for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END - if ( shape->marker[i] ) { - SPMarker* marker = SP_MARKER (shape->marker[i]); - SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker)); + if (marker_item) { + /* Get reference to last curve in the path. + * For moveto-only path, this returns the "closing line segment". */ + Geom::Path const &path_last = pathv.back(); + unsigned int index = path_last.size_default(); + if (index > 0) { + index--; + } + Geom::Curve const &lastcurve = path_last[index]; - if (marker_item) { - /* Get reference to last curve in the path. - * For moveto-only path, this returns the "closing line segment". */ - unsigned int index = path_it->size_default(); - if (index > 0) { - index--; - } - Geom::Curve const &lastcurve = (*path_it)[index]; + Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; + } - Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } + // total marker transform + tr = marker_item->transform * marker->c2p * tr * transform; - // total marker transform - tr = marker_item->transform * marker->c2p * tr * transform; - - // get bbox of the marker with that transform - NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); - // union it with the shape bbox - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } + // get bbox of the marker with that transform + NRRect marker_bbox; + sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); + // union it with the shape bbox + nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } } } @@ -693,19 +698,20 @@ sp_print_stroke (ctx, shape->curve->get_pathvector(), &i2d, style, &pbox, &dbox, &bbox); } - /* TODO: make code prettier: lots of variables can be taken out of the loop! */ + /** \todo make code prettier */ Geom::PathVector const & pathv = shape->curve->get_pathvector(); + // START marker + if ( shape->marker[SP_MARKER_LOC_START] || shape->marker[SP_MARKER_LOC]) { + Geom::Matrix tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front())); + if (shape->marker[SP_MARKER_LOC_START]) { + sp_shape_print_invoke_marker_printing(shape->marker[SP_MARKER_LOC_START], tr, style, ctx); + } + if (shape->marker[SP_MARKER_LOC]) { + sp_shape_print_invoke_marker_printing(shape->marker[SP_MARKER_LOC], tr, style, ctx); + } + } + // MID marker for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - if ( shape->marker[SP_MARKER_LOC_START] || shape->marker[SP_MARKER_LOC]) { - Geom::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front())); - if (shape->marker[SP_MARKER_LOC_START]) { - sp_shape_print_invoke_marker_printing(shape->marker[SP_MARKER_LOC_START], tr, style, ctx); - } - if (shape->marker[SP_MARKER_LOC]) { - sp_shape_print_invoke_marker_printing(shape->marker[SP_MARKER_LOC], tr, style, ctx); - } - } - if ( (shape->marker[SP_MARKER_LOC_MID] || shape->marker[SP_MARKER_LOC]) && (path_it->size_default() > 1) ) { Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve @@ -727,25 +733,26 @@ ++curve_it2; } } + } + // END marker + if ( shape->marker[SP_MARKER_LOC_END] || shape->marker[SP_MARKER_LOC]) { + /* Get reference to last curve in the path. + * For moveto-only path, this returns the "closing line segment". */ + Geom::Path const &path_last = pathv.back(); + unsigned int index = path_last.size_default(); + if (index > 0) { + index--; + } + Geom::Curve const &lastcurve = path_last[index]; - if ( shape->marker[SP_MARKER_LOC_END] || shape->marker[SP_MARKER_LOC]) { - /* Get reference to last curve in the path. - * For moveto-only path, this returns the "closing line segment". */ - unsigned int index = path_it->size_default(); - if (index > 0) { - index--; - } - Geom::Curve const &lastcurve = (*path_it)[index]; + Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); - Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); - - if (shape->marker[SP_MARKER_LOC_END]) { - sp_shape_print_invoke_marker_printing(shape->marker[SP_MARKER_LOC_END], tr, style, ctx); - } - if (shape->marker[SP_MARKER_LOC]) { - sp_shape_print_invoke_marker_printing(shape->marker[SP_MARKER_LOC], tr, style, ctx); - } + if (shape->marker[SP_MARKER_LOC_END]) { + sp_shape_print_invoke_marker_printing(shape->marker[SP_MARKER_LOC_END], tr, style, ctx); } + if (shape->marker[SP_MARKER_LOC]) { + sp_shape_print_invoke_marker_printing(shape->marker[SP_MARKER_LOC], tr, style, ctx); + } } if (add_comments) { @@ -863,6 +870,9 @@ sp_shape_number_of_markers (SPShape *shape, int type) { Geom::PathVector const & pathv = shape->curve->get_pathvector(); + if (pathv.size() == 0) { + return 0; + } switch(type) { case SP_MARKER_LOC: @@ -879,7 +889,8 @@ } } case SP_MARKER_LOC_START: - return shape->marker[SP_MARKER_LOC_START] ? pathv.size() : 0; + // there is only a start marker on the first path of a pathvector + return shape->marker[SP_MARKER_LOC_START] ? 1 : 0; case SP_MARKER_LOC_MID: { @@ -897,7 +908,8 @@ case SP_MARKER_LOC_END: { - return shape->marker[SP_MARKER_LOC_END] ? pathv.size() : 0; + // there is only an end marker on the last path of a pathvector + return shape->marker[SP_MARKER_LOC_END] ? 1 : 0; } default: Index: src/splivarot.cpp =================================================================== --- src/splivarot.cpp (revision 22518) +++ src/splivarot.cpp (working copy) @@ -856,16 +856,18 @@ SPShape *shape = SP_SHAPE(item); Geom::PathVector const & pathv = curve->get_pathvector(); + + // START marker + for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START + if ( SPObject *marker_obj = shape->marker[i] ) { + Geom::Matrix const m (sp_shape_marker_get_transform_at_start(pathv.front().front())); + sp_selected_path_outline_add_marker( marker_obj, m, + Geom::Scale(i_style->stroke_width.computed), transform, + g_repr, xml_doc, doc ); + } + } + // MID marker for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START - if ( SPObject *marker_obj = shape->marker[i] ) { - Geom::Matrix const m (sp_shape_marker_get_transform_at_start(path_it->front())); - sp_selected_path_outline_add_marker( marker_obj, m, - Geom::Scale(i_style->stroke_width.computed), transform, - g_repr, xml_doc, doc ); - } - } - for (int i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID SPObject *midmarker_obj = shape->marker[i]; if ( midmarker_obj && (path_it->size_default() > 1) ) { @@ -887,22 +889,23 @@ } } } + } + // END marker + for (int i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END + if ( SPObject *marker_obj = shape->marker[i] ) { + /* Get reference to last curve in the path. + * For moveto-only path, this returns the "closing line segment". */ + Geom::Path const &path_last = pathv.back(); + unsigned int index = path_last.size_default(); + if (index > 0) { + index--; + } + Geom::Curve const &lastcurve = path_last[index]; - for (int i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END - if ( SPObject *marker_obj = shape->marker[i] ) { - /* Get reference to last curve in the path. - * For moveto-only path, this returns the "closing line segment". */ - unsigned int index = path_it->size_default(); - if (index > 0) { - index--; - } - Geom::Curve const &lastcurve = (*path_it)[index]; - - Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve); - sp_selected_path_outline_add_marker( marker_obj, m, - Geom::Scale(i_style->stroke_width.computed), transform, - g_repr, xml_doc, doc ); - } + Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve); + sp_selected_path_outline_add_marker( marker_obj, m, + Geom::Scale(i_style->stroke_width.computed), transform, + g_repr, xml_doc, doc ); } }