~ubuntu-branches/ubuntu/oneiric/inkscape/oneiric-updates

« back to all changes in this revision

Viewing changes to src/extension/internal/cairo-renderer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2009-12-24 16:10:36 UTC
  • Revision ID: james.westby@ubuntu.com-20091224161036-low9f46u1pveqd6i
Tags: 0.47.0-1ubuntu2
Brown paper bag update: actually use the correct version of the
source tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
 
193
193
    ctx->renderPathVector(pathv, style, &pbox);
194
194
 
195
 
    for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
196
 
      // START position
197
 
        for (int i = 0; i < 2; i++) {  // SP_MARKER_LOC and SP_MARKER_LOC_START
198
 
            if ( shape->marker[i] ) {
199
 
                SPMarker* marker = SP_MARKER (shape->marker[i]);
 
195
    // START marker
 
196
    for (int i = 0; i < 2; i++) {  // SP_MARKER_LOC and SP_MARKER_LOC_START
 
197
        if ( shape->marker[i] ) {
 
198
            SPMarker* marker = SP_MARKER (shape->marker[i]);
 
199
            Geom::Matrix tr;
 
200
            if (marker->orient_auto) {
 
201
                tr = sp_shape_marker_get_transform_at_start(pathv.begin()->front());
 
202
            } else {
 
203
                tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(pathv.begin()->front().pointAt(0));
 
204
            }
 
205
            sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx);
 
206
        }
 
207
    }
 
208
    // MID marker
 
209
    for (int i = 0; i < 3; i += 2) {  // SP_MARKER_LOC and SP_MARKER_LOC_MID
 
210
        if ( !shape->marker[i] ) continue;
 
211
        SPMarker* marker = SP_MARKER (shape->marker[i]);
 
212
        for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
 
213
            // START position
 
214
            if ( path_it != pathv.begin() 
 
215
                 && ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there
 
216
            {
200
217
                Geom::Matrix tr;
201
218
                if (marker->orient_auto) {
202
219
                    tr = sp_shape_marker_get_transform_at_start(path_it->front());
205
222
                }
206
223
                sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx);
207
224
            }
208
 
        }
209
 
 
210
 
      // MID position
211
 
        for (int i = 0; i < 3; i += 2) {  // SP_MARKER_LOC and SP_MARKER_LOC_MID
212
 
            if ( shape->marker[i] && (path_it->size_default() > 1) ) {
 
225
            // MID position
 
226
            if (path_it->size_default() > 1) {
213
227
                Geom::Path::const_iterator curve_it1 = path_it->begin();      // incoming curve
214
228
                Geom::Path::const_iterator curve_it2 = ++(path_it->begin());  // outgoing curve
215
229
                while (curve_it2 != path_it->end_default())
217
231
                    /* Put marker between curve_it1 and curve_it2.
218
232
                     * Loop to end_default (so including closing segment), because when a path is closed,
219
233
                     * there should be a midpoint marker between last segment and closing straight line segment */
220
 
 
221
 
                    SPMarker* marker = SP_MARKER (shape->marker[i]);
222
 
 
223
234
                    Geom::Matrix tr;
224
235
                    if (marker->orient_auto) {
225
236
                        tr = sp_shape_marker_get_transform(*curve_it1, *curve_it2);
233
244
                    ++curve_it2;
234
245
                }
235
246
            }
236
 
        }
237
 
 
238
 
      // END position
239
 
        for (int i = 0; i < 4; i += 3) {  // SP_MARKER_LOC and SP_MARKER_LOC_END
240
 
            if ( shape->marker[i] ) {
241
 
                SPMarker* marker = SP_MARKER (shape->marker[i]);
242
 
 
243
 
                /* Get reference to last curve in the path.
244
 
                 * For moveto-only path, this returns the "closing line segment". */
245
 
                unsigned int index = path_it->size_default();
246
 
                if (index > 0) {
247
 
                    index--;
248
 
                }
249
 
                Geom::Curve const &lastcurve = (*path_it)[index];
250
 
 
 
247
            // END position
 
248
            if ( path_it != (pathv.end()-1) && !path_it->empty()) {
 
249
                Geom::Curve const &lastcurve = path_it->back_default();
251
250
                Geom::Matrix tr;
252
251
                if (marker->orient_auto) {
253
252
                    tr = sp_shape_marker_get_transform_at_end(lastcurve);
254
253
                } else {
255
254
                    tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(lastcurve.pointAt(1));
256
255
                }
257
 
 
258
256
                sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx);
259
257
            }
260
258
        }
261
259
    }
 
260
    // END marker
 
261
    for (int i = 0; i < 4; i += 3) {  // SP_MARKER_LOC and SP_MARKER_LOC_END
 
262
        if ( shape->marker[i] ) {
 
263
            SPMarker* marker = SP_MARKER (shape->marker[i]);
 
264
 
 
265
            /* Get reference to last curve in the path.
 
266
             * For moveto-only path, this returns the "closing line segment". */
 
267
            Geom::Path const &path_last = pathv.back();
 
268
            unsigned int index = path_last.size_default();
 
269
            if (index > 0) {
 
270
                index--;
 
271
            }
 
272
            Geom::Curve const &lastcurve = path_last[index];
 
273
 
 
274
            Geom::Matrix tr;
 
275
            if (marker->orient_auto) {
 
276
                tr = sp_shape_marker_get_transform_at_end(lastcurve);
 
277
            } else {
 
278
                tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(lastcurve.pointAt(1));
 
279
            }
 
280
 
 
281
            sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx);
 
282
        }
 
283
    }
262
284
}
263
285
 
264
286
static void sp_group_render(SPItem *item, CairoRenderContext *ctx)