From: johanengelen Date: Tue, 12 Aug 2008 22:42:21 +0000 (+0000) Subject: NR:: to Geom:: for most of src/extension/ X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=17d87f5698f5c2958d38c6a6207c7b322a7adaf9;p=inkscape.git NR:: to Geom:: for most of src/extension/ --- diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 0f2580eb9..6090b72d0 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -148,7 +148,7 @@ Implementation::finish(Inkscape::Extension::Print */*module*/) /* Rendering methods */ unsigned int -Implementation::bind(Inkscape::Extension::Print */*module*/, NR::Matrix const */*transform*/, float /*opacity*/) +Implementation::bind(Inkscape::Extension::Print */*module*/, Geom::Matrix const */*transform*/, float /*opacity*/) { return 0; } @@ -166,14 +166,14 @@ Implementation::comment(Inkscape::Extension::Print */*module*/, char const */*co } unsigned int -Implementation::fill(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, NR::Matrix const */*ctm*/, SPStyle const */*style*/, +Implementation::fill(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Matrix const */*ctm*/, SPStyle const */*style*/, NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) { return 0; } unsigned int -Implementation::stroke(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, NR::Matrix const */*transform*/, SPStyle const */*style*/, +Implementation::stroke(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Matrix const */*transform*/, SPStyle const */*style*/, NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) { return 0; @@ -181,14 +181,14 @@ Implementation::stroke(Inkscape::Extension::Print */*module*/, Geom::PathVector unsigned int Implementation::image(Inkscape::Extension::Print */*module*/, unsigned char */*px*/, unsigned int /*w*/, unsigned int /*h*/, unsigned int /*rs*/, - NR::Matrix const */*transform*/, SPStyle const */*style*/) + Geom::Matrix const */*transform*/, SPStyle const */*style*/) { return 0; } unsigned int Implementation::text(Inkscape::Extension::Print */*module*/, char const */*text*/, - NR::Point /*p*/, SPStyle const */*style*/) + Geom::Point /*p*/, SPStyle const */*style*/) { return 0; } diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index d90d2e7a9..9de70dce7 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -100,20 +100,20 @@ public: /* ----- Rendering methods ----- */ virtual unsigned bind(Inkscape::Extension::Print *module, - NR::Matrix const *transform, + Geom::Matrix const *transform, float opacity); virtual unsigned release(Inkscape::Extension::Print *module); virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment); virtual unsigned fill(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, - NR::Matrix const *ctm, + Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned stroke(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, - NR::Matrix const *transform, + Geom::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, @@ -123,11 +123,11 @@ public: unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *transform, + Geom::Matrix const *transform, SPStyle const *style); virtual unsigned text(Inkscape::Extension::Print *module, char const *text, - NR::Point p, + Geom::Point p, SPStyle const *style); virtual void processPath(Inkscape::XML::Node * node); }; diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index b19e4b316..13302831e 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -816,7 +816,7 @@ CairoRenderContext::finish(void) } void -CairoRenderContext::transform(NR::Matrix const *transform) +CairoRenderContext::transform(Geom::Matrix const *transform) { g_assert( _is_valid ); @@ -829,7 +829,7 @@ CairoRenderContext::transform(NR::Matrix const *transform) } void -CairoRenderContext::setTransform(NR::Matrix const *transform) +CairoRenderContext::setTransform(Geom::Matrix const *transform) { g_assert( _is_valid ); @@ -840,7 +840,7 @@ CairoRenderContext::setTransform(NR::Matrix const *transform) } void -CairoRenderContext::getTransform(NR::Matrix *copy) const +CairoRenderContext::getTransform(Geom::Matrix *copy) const { g_assert( _is_valid ); @@ -855,12 +855,12 @@ CairoRenderContext::getTransform(NR::Matrix *copy) const } void -CairoRenderContext::getParentTransform(NR::Matrix *copy) const +CairoRenderContext::getParentTransform(Geom::Matrix *copy) const { g_assert( _is_valid ); CairoRenderState *parent_state = getParentState(); - memcpy(copy, &parent_state->transform, sizeof(NR::Matrix)); + memcpy(copy, &parent_state->transform, sizeof(Geom::Matrix)); } void @@ -908,9 +908,9 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver SPPattern *pat = SP_PATTERN (paintserver); - NR::Matrix ps2user, pcs2dev; - ps2user.set_identity(); - pcs2dev.set_identity(); + Geom::Matrix ps2user, pcs2dev; + ps2user = Geom::identity(); + pcs2dev = Geom::identity(); double x = pattern_x(pat); double y = pattern_y(pat); @@ -922,7 +922,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver TRACE(("%f x %f pattern\n", width, height)); if (pbox && pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { - //NR::Matrix bbox2user (pbox->x1 - pbox->x0, 0.0, 0.0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + //Geom::Matrix bbox2user (pbox->x1 - pbox->x0, 0.0, 0.0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); bbox_width_scaler = pbox->x1 - pbox->x0; bbox_height_scaler = pbox->y1 - pbox->y0; ps2user[4] = x * bbox_width_scaler + pbox->x0; @@ -935,7 +935,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver } // apply pattern transformation - NR::Matrix pattern_transform(pattern_patternTransform(pat)); + Geom::Matrix pattern_transform(pattern_patternTransform(pat)); ps2user *= pattern_transform; // create pattern contents coordinate system @@ -964,7 +964,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // calculate the size of the surface which has to be created // the scaling needs to be taken into account in the ctm after the pattern transformation - NR::Matrix temp; + Geom::Matrix temp; temp = pattern_transform * _state->transform; double width_scaler = sqrt(temp[0] * temp[0] + temp[2] * temp[2]); double height_scaler = sqrt(temp[1] * temp[1] + temp[3] * temp[3]); @@ -986,8 +986,8 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver double scale_height = surface_height / (bbox_height_scaler * height); if (scale_width != 1.0 || scale_height != 1.0 || _vector_based_target) { TRACE(("needed to scale with %f %f\n", scale_width, scale_height)); - pcs2dev *= NR::scale(1.0 / scale_width, 1.0 / scale_height); - ps2user *= NR::scale(scale_width, scale_height); + pcs2dev *= Geom::Scale(1.0 / scale_width, 1.0 / scale_height); + ps2user *= Geom::Scale(scale_width, scale_height); } pattern_ctx->setTransform(&pcs2dev); @@ -1054,17 +1054,17 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain sp_gradient_ensure_vector(SP_GRADIENT(lg)); // when exporting from commandline, vector is not built - NR::Point p1 (lg->x1.computed, lg->y1.computed); - NR::Point p2 (lg->x2.computed, lg->y2.computed); + Geom::Point p1 (lg->x1.computed, lg->y1.computed); + Geom::Point p2 (lg->x2.computed, lg->y2.computed); if (pbox && SP_GRADIENT(lg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { // convert to userspace - NR::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + Geom::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); p1 *= bbox2user; p2 *= bbox2user; } // create linear gradient pattern - pattern = cairo_pattern_create_linear(p1[NR::X], p1[NR::Y], p2[NR::X], p2[NR::Y]); + pattern = cairo_pattern_create_linear(p1[Geom::X], p1[Geom::Y], p2[Geom::X], p2[Geom::Y]); // add stops for (gint i = 0; unsigned(i) < lg->vector.stops.size(); i++) { @@ -1078,14 +1078,14 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain sp_gradient_ensure_vector(SP_GRADIENT(rg)); // when exporting from commandline, vector is not built - NR::Point c (rg->cx.computed, rg->cy.computed); - NR::Point f (rg->fx.computed, rg->fy.computed); + Geom::Point c (rg->cx.computed, rg->cy.computed); + Geom::Point f (rg->fx.computed, rg->fy.computed); double r = rg->r.computed; if (pbox && SP_GRADIENT(rg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) apply_bbox2user = true; // create radial gradient pattern - pattern = cairo_pattern_create_radial(f[NR::X], f[NR::Y], 0, c[NR::X], c[NR::Y], r); + pattern = cairo_pattern_create_radial(f[Geom::X], f[Geom::Y], 0, c[Geom::X], c[Geom::Y], r); // add stops for (gint i = 0; unsigned(i) < rg->vector.stops.size(); i++) { @@ -1323,7 +1323,7 @@ CairoRenderContext::renderPath(const_NRBPath const *bpath, SPStyle const *style, bool CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *image_transform, SPStyle const *style) + Geom::Matrix const *image_transform, SPStyle const *style) { g_assert( _is_valid ); @@ -1438,7 +1438,7 @@ CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector const &glyphtext, SPStyle const *style) { // create a cairo_font_face from PangoFont @@ -1572,7 +1572,7 @@ CairoRenderContext::_concatTransform(cairo_t *cr, double xx, double yx, double x } void -CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, NR::Matrix const *transform) +CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Matrix const *transform) { matrix->xx = (*transform)[0]; matrix->yx = (*transform)[1]; @@ -1583,7 +1583,7 @@ CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, NR::Matrix const *t } void -CairoRenderContext::_concatTransform(cairo_t *cr, NR::Matrix const *transform) +CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Matrix const *transform) { _concatTransform(cr, (*transform)[0], (*transform)[1], (*transform)[2], (*transform)[3], diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 68a615234..fe76cb105 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -59,7 +59,7 @@ struct CairoRenderState { SPClipPath *clip_path; SPMask* mask; - NR::Matrix transform; // the CTM + Geom::Matrix transform; // the CTM }; class CairoRenderContext { @@ -127,10 +127,10 @@ public: CairoRenderState *getParentState(void) const; void setStateForStyle(SPStyle const *style); - void transform(NR::Matrix const *transform); - void setTransform(NR::Matrix const *transform); - void getTransform(NR::Matrix *copy) const; - void getParentTransform(NR::Matrix *copy) const; + void transform(Geom::Matrix const *transform); + void setTransform(Geom::Matrix const *transform); + void getTransform(Geom::Matrix *copy) const; + void getParentTransform(Geom::Matrix *copy) const; /* Clipping methods */ void addClipPath(NArtBpath const *bp, SPIEnum const *fill_rule); @@ -140,8 +140,8 @@ public: bool renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox); bool renderPath(const_NRBPath const *bpath, SPStyle const *style, NRRect const *pbox); bool renderImage(unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *image_transform, SPStyle const *style); - bool renderGlyphtext(PangoFont *font, NR::Matrix const *font_matrix, + Geom::Matrix const *image_transform, SPStyle const *style); + bool renderGlyphtext(PangoFont *font, Geom::Matrix const *font_matrix, std::vector const &glyphtext, SPStyle const *style); /* More general rendering methods will have to be added (like fill, stroke) */ @@ -191,9 +191,9 @@ protected: void _setFillStyle(SPStyle const *style, NRRect const *pbox); void _setStrokeStyle(SPStyle const *style, NRRect const *pbox); - void _initCairoMatrix(cairo_matrix_t *matrix, NR::Matrix const *transform); + void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Matrix const *transform); void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0); - void _concatTransform(cairo_t *cr, NR::Matrix const *transform); + void _concatTransform(cairo_t *cr, Geom::Matrix const *transform); CairoRenderState *_createState(void); }; diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 914a543f2..8c27632e1 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -135,7 +135,7 @@ CairoRenderer::createContext(void) // create initial render state CairoRenderState *state = new_context->_createState(); - state->transform.set_identity(); + state->transform = Geom::identity(); new_context->_state_stack = g_slist_prepend(new_context->_state_stack, state); new_context->_state = state; @@ -175,7 +175,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) if (!shape->curve) return; /* fixme: Think (Lauris) */ - sp_item_invoke_bbox(item, &pbox, NR::identity(), TRUE); + sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE); SPStyle* style = SP_OBJECT_STYLE (item); CairoRenderer *renderer = ctx->getRenderer(); @@ -190,15 +190,15 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_START]); SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_START])); - NR::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front())); + Geom::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front())); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } - tr = marker_item->transform * marker->c2p * tr; + tr = (Geom::Matrix)marker_item->transform * (Geom::Matrix)marker->c2p * tr; - NR::Matrix old_tr = marker_item->transform; + Geom::Matrix old_tr = marker_item->transform; marker_item->transform = tr; renderer->renderItem (ctx, marker_item); marker_item->transform = old_tr; @@ -216,15 +216,15 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_MID]); SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_MID])); - NR::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); + Geom::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } - tr = marker_item->transform * marker->c2p * tr; + tr = (Geom::Matrix)marker_item->transform * (Geom::Matrix)marker->c2p * tr; - NR::Matrix old_tr = marker_item->transform; + Geom::Matrix old_tr = marker_item->transform; marker_item->transform = tr; renderer->renderItem (ctx, marker_item); marker_item->transform = old_tr; @@ -246,15 +246,15 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) } Geom::Curve const &lastcurve = (*path_it)[index]; - NR::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); + Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } - tr = marker_item->transform * marker->c2p * tr; + tr = (Geom::Matrix)marker_item->transform * (Geom::Matrix)marker->c2p * tr; - NR::Matrix old_tr = marker_item->transform; + Geom::Matrix old_tr = marker_item->transform; marker_item->transform = tr; renderer->renderItem (ctx, marker_item); marker_item->transform = old_tr; @@ -285,7 +285,7 @@ static void sp_use_render(SPItem *item, CairoRenderContext *ctx) CairoRenderer *renderer = ctx->getRenderer(); if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { - NR::Matrix tp(NR::translate(use->x.computed, use->y.computed)); + Geom::Matrix tp(Geom::Translate(use->x.computed, use->y.computed)); ctx->pushState(); ctx->transform(&tp); translated = true; @@ -342,9 +342,9 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx) ctx->addClippingRect(image->x.computed, image->y.computed, image->width.computed, image->height.computed); } - NR::translate tp(x, y); - NR::scale s(width / (double)w, height / (double)h); - NR::Matrix t(s * tp); + Geom::Translate tp(x, y); + Geom::Scale s(width / (double)w, height / (double)h); + Geom::Matrix t(s * tp); ctx->renderImage (px, w, h, rs, &t, SP_OBJECT_STYLE (item)); } @@ -361,7 +361,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) // apply viewbox if set if (0 /*symbol->viewBox_set*/) { - NR::Matrix vb2user; + Geom::Matrix vb2user; double x, y, width, height; double view_width, view_height; x = 0.0; @@ -376,7 +376,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) &x, &y,&width, &height); // [itemTransform *] translate(x, y) * scale(w/vw, h/vh) * translate(-vx, -vy); - vb2user.set_identity(); + vb2user = Geom::identity(); vb2user[0] = width / view_width; vb2user[3] = height / view_height; vb2user[4] = x - symbol->viewBox.x0 * vb2user[0]; @@ -399,7 +399,8 @@ static void sp_root_render(SPItem *item, CairoRenderContext *ctx) ctx->pushState(); renderer->setStateForItem(ctx, item); - ctx->transform(&root->c2p); + Geom::Matrix tempmat (root->c2p); + ctx->transform(&tempmat); sp_group_render(item, ctx); ctx->popState(); } @@ -417,7 +418,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); // Get the bounding box of the selection - //boost::optional _bbox = item->getBounds(sp_item_i2d_affine(item)); + //boost::optional _bbox = item->getBounds(sp_item_i2d_affine(item)); // NRRect bbox = item->getBounds(sp_item_i2d_affine(item)); NRRect bbox(item->getBounds(sp_item_i2d_affine(item))); @@ -472,8 +473,8 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } */ // Calculate the matrix that will be applied to the image so that it exactly overlaps the source objects - NR::Matrix eek = sp_item_i2d_affine (SP_ITEM(parent_object)); - NR::Matrix t; + Geom::Matrix eek = sp_item_i2d_affine (SP_ITEM(parent_object)); + Geom::Matrix t; double shift_x = bbox.x0; double shift_y = bbox.y1; @@ -481,9 +482,9 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) shift_x = round (shift_x); shift_y = -round (-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone } - t = (NR::Matrix)(NR::scale(1, -1) * (NR::Matrix)(NR::translate (shift_x, shift_y)* eek.inverse())); + t = (Geom::Matrix)(Geom::Scale(1, -1) * (Geom::Matrix)(Geom::Translate (shift_x, shift_y)* eek.inverse())); - //t = t * ((NR::Matrix)ctx->getCurrentState()->transform).inverse(); + //t = t * ((Geom::Matrix)ctx->getCurrentState()->transform).inverse(); // Do the export GdkPixbuf *pb = sp_generate_internal_bitmap(document, NULL, @@ -501,9 +502,9 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) unsigned int w = gdk_pixbuf_get_width(pb); unsigned int h = gdk_pixbuf_get_height(pb); unsigned int rs = gdk_pixbuf_get_rowstride(pb); - NR::Matrix matrix; + Geom::Matrix matrix; matrix = t; - //matrix = ((NR::Matrix)ctx->getCurrentState()->transform).inverse(); + //matrix = ((Geom::Matrix)ctx->getCurrentState()->transform).inverse(); //matrix.set_identity(); ctx->renderImage (px, w, h, rs, &matrix, SP_OBJECT_STYLE (item)); @@ -609,7 +610,8 @@ CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) state->merge_opacity = FALSE; ctx->pushLayer(); } - ctx->transform(&item->transform); + Geom::Matrix tempmat (item->transform); + ctx->transform(&tempmat); sp_item_invoke_render(item, ctx); if (state->need_layer) @@ -667,11 +669,11 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) CairoRenderContext::CairoRenderMode saved_mode = ctx->getRenderMode(); ctx->setRenderMode(CairoRenderContext::RENDER_MODE_CLIP); - NR::Matrix saved_ctm; + Geom::Matrix saved_ctm; if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { //SP_PRINT_DRECT("clipd", cp->display->bbox); NRRect clip_bbox(cp->display->bbox); - NR::Matrix t(NR::scale(clip_bbox.x1 - clip_bbox.x0, clip_bbox.y1 - clip_bbox.y0)); + Geom::Matrix t(Geom::Scale(clip_bbox.x1 - clip_bbox.x0, clip_bbox.y1 - clip_bbox.y0)); t[4] = clip_bbox.x0; t[5] = clip_bbox.y0; t *= ctx->getCurrentState()->transform; @@ -712,7 +714,7 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) NRRect mask_bbox(mask->display->bbox); // TODO: should the bbox be transformed if maskUnits != userSpaceOnUse ? if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - NR::Matrix t(NR::scale(mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0)); + Geom::Matrix t(Geom::Scale(mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0)); t[4] = mask_bbox.x0; t[5] = mask_bbox.y0; t *= ctx->getCurrentState()->transform; diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 6e0a7bf0b..f4d021830 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -241,7 +241,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) g_free(local_fn); g_free(unicode_fn); - m_tr_stack.push( NR::scale(1, -1) * NR::translate(0, sp_document_height(doc))); + m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, sp_document_height(doc))); return 0; } @@ -317,7 +317,7 @@ PrintEmfWin32::destroy_brush() void -PrintEmfWin32::create_pen(SPStyle const *style, const NR::Matrix *transform) +PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Matrix *transform) { if (style) { float rgb[3]; @@ -335,16 +335,16 @@ PrintEmfWin32::create_pen(SPStyle const *style, const NR::Matrix *transform) DWORD *dash = NULL; float oldmiterlimit; - using NR::X; - using NR::Y; + using Geom::X; + using Geom::Y; - NR::Matrix tf = *transform; + Geom::Matrix tf = *transform; - NR::Point zero(0, 0); - NR::Point one(1, 1); - NR::Point p0(zero * tf); - NR::Point p1(one * tf); - NR::Point p(p1 - p0); + Geom::Point zero(0, 0); + Geom::Point one(1, 1); + Geom::Point p0(zero * tf); + Geom::Point p1(one * tf); + Geom::Point p(p1 - p0); double scale = sqrt( (p[X]*p[X]) + (p[Y]*p[Y]) ) / sqrt(2); @@ -513,12 +513,12 @@ PrintEmfWin32::cmp_bpath(const NArtBpath *bp1, const NArtBpath *bp2) } unsigned int -PrintEmfWin32::bind(Inkscape::Extension::Print *mod, NR::Matrix const *transform, float opacity) +PrintEmfWin32::bind(Inkscape::Extension::Print *mod, Geom::Matrix const *transform, float opacity) { - NR::Matrix tr = *transform; + Geom::Matrix tr = *transform; if (m_tr_stack.size()) { - NR::Matrix tr_top = m_tr_stack.top(); + Geom::Matrix tr_top = m_tr_stack.top(); m_tr_stack.push(tr * tr_top); } else { m_tr_stack.push(tr); @@ -536,12 +536,12 @@ PrintEmfWin32::release(Inkscape::Extension::Print *mod) unsigned int PrintEmfWin32::fill(Inkscape::Extension::Print *mod, - Geom::PathVector const &pathv, NR::Matrix const *transform, SPStyle const *style, + Geom::PathVector const &pathv, Geom::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!hdc) return 0; - NR::Matrix tf = m_tr_stack.top(); + Geom::Matrix tf = m_tr_stack.top(); flush_fill(); // flush any pending fills @@ -567,12 +567,12 @@ PrintEmfWin32::fill(Inkscape::Extension::Print *mod, unsigned int PrintEmfWin32::stroke (Inkscape::Extension::Print *mod, - Geom::PathVector const &pathv, const NR::Matrix *transform, const SPStyle *style, + Geom::PathVector const &pathv, const Geom::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { if (!hdc) return 0; - NR::Matrix tf = m_tr_stack.top(); + Geom::Matrix tf = m_tr_stack.top(); NArtBpath * bpath = BPath_from_2GeomPath(pathv); @@ -610,7 +610,7 @@ PrintEmfWin32::stroke (Inkscape::Extension::Print *mod, bool -PrintEmfWin32::print_simple_shape(const NArtBpath *bpath, const NR::Matrix *transform, NRRect const *pbox) +PrintEmfWin32::print_simple_shape(const NArtBpath *bpath, const Geom::Matrix *transform, NRRect const *pbox) { NR::Matrix tf = *transform; const NArtBpath *bp = bpath; @@ -645,12 +645,12 @@ PrintEmfWin32::print_simple_shape(const NArtBpath *bpath, const NR::Matrix *tran bp = bpath; while (bp->code != NR_END) { - using NR::X; - using NR::Y; + using Geom::X; + using Geom::Y; - NR::Point p1(bp->c(1) * tf); - NR::Point p2(bp->c(2) * tf); - NR::Point p3(bp->c(3) * tf); + Geom::Point p1(bp->c(1) * tf); + Geom::Point p2(bp->c(2) * tf); + Geom::Point p3(bp->c(3) * tf); p1[X] = (p1[X] * IN_PER_PX * dwDPI); p2[X] = (p2[X] * IN_PER_PX * dwDPI); @@ -768,12 +768,12 @@ PrintEmfWin32::print_simple_shape(const NArtBpath *bpath, const NR::Matrix *tran } unsigned int -PrintEmfWin32::print_bpath(const NArtBpath *bp, const NR::Matrix *transform, NRRect const *pbox) +PrintEmfWin32::print_bpath(NArtBpath const *bp, Geom::Matrix const *transform, NRRect const *pbox) { unsigned int closed; NR::Matrix tf = *transform; - simple_shape = print_simple_shape(bp, &tf, pbox); + simple_shape = print_simple_shape(bp, transform, pbox); if (simple_shape) return TRUE; @@ -781,12 +781,12 @@ PrintEmfWin32::print_bpath(const NArtBpath *bp, const NR::Matrix *transform, NRR BeginPath( hdc ); closed = FALSE; while (bp->code != NR_END) { - using NR::X; - using NR::Y; + using Geom::X; + using Geom::Y; - NR::Point p1(bp->c(1) * tf); - NR::Point p2(bp->c(2) * tf); - NR::Point p3(bp->c(3) * tf); + Geom::Point p1(bp->c(1) * tf); + Geom::Point p2(bp->c(2) * tf); + Geom::Point p3(bp->c(3) * tf); p1[X] = (p1[X] * IN_PER_PX * dwDPI); p2[X] = (p2[X] * IN_PER_PX * dwDPI); @@ -854,7 +854,7 @@ PrintEmfWin32::textToPath(Inkscape::Extension::Print * ext) } unsigned int -PrintEmfWin32::text(Inkscape::Extension::Print *mod, char const *text, NR::Point p, +PrintEmfWin32::text(Inkscape::Extension::Print *mod, char const *text, Geom::Point p, SPStyle const *const style) { if (!hdc) return 0; @@ -961,14 +961,14 @@ PrintEmfWin32::text(Inkscape::Extension::Print *mod, char const *text, NR::Point // Transparent text background SetBkMode(hdc, TRANSPARENT); - NR::Matrix tf = m_tr_stack.top(); + Geom::Matrix tf = m_tr_stack.top(); p = p * tf; - p[NR::X] = (p[NR::X] * IN_PER_PX * dwDPI); - p[NR::Y] = (p[NR::Y] * IN_PER_PX * dwDPI); + p[Geom::X] = (p[Geom::X] * IN_PER_PX * dwDPI); + p[Geom::Y] = (p[Geom::Y] * IN_PER_PX * dwDPI); - LONG const xpos = (LONG) round(p[NR::X]); - LONG const ypos = (LONG) round(rc.bottom-p[NR::Y]); + LONG const xpos = (LONG) round(p[Geom::X]); + LONG const ypos = (LONG) round(rc.bottom-p[Geom::Y]); if (PrintWin32::is_os_wide()) { gunichar2 *unicode_text = g_utf8_to_utf16( text, -1, NULL, NULL, NULL ); diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index 11b265dcc..63232dad1 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -44,18 +44,18 @@ class PrintEmfWin32 : public Inkscape::Extension::Implementation::Implementation HBRUSH hbrush, hbrushOld; HPEN hpen, hpenOld; - std::stack m_tr_stack; + std::stack m_tr_stack; NArtBpath *fill_path; NArtBpath *fill_path_copy; - NR::Matrix fill_transform; + Geom::Matrix fill_transform; NRRect fill_pbox; -// NR::Matrix text_transform; +// Geom::Matrix text_transform; bool stroke_and_fill; bool fill_only; bool simple_shape; - unsigned int print_bpath (const NArtBpath *bp, const NR::Matrix *transform, NRRect const *pbox); - bool print_simple_shape (const NArtBpath *bp, const NR::Matrix *transform, NRRect const *pbox); + unsigned int print_bpath (const NArtBpath *bp, const Geom::Matrix *transform, NRRect const *pbox); + bool print_simple_shape (const NArtBpath *bp, const Geom::Matrix *transform, NRRect const *pbox); public: PrintEmfWin32 (void); @@ -68,17 +68,17 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int fill (Inkscape::Extension::Print * module, - Geom::PathVector const &pathv, const NR::Matrix *ctm, const SPStyle *style, + Geom::PathVector const &pathv, const Geom::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int stroke (Inkscape::Extension::Print * module, - Geom::PathVector const &pathv, const NR::Matrix *transform, const SPStyle *style, + Geom::PathVector const &pathv, const Geom::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, - NR::Point p, SPStyle const *style); + Geom::Point p, SPStyle const *style); bool textToPath (Inkscape::Extension::Print * ext); static void init (void); @@ -88,7 +88,7 @@ protected: void destroy_brush(); - void create_pen(SPStyle const *style, const NR::Matrix *transform); + void create_pen(SPStyle const *style, const Geom::Matrix *transform); void destroy_pen(); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index e206b2a68..729b53cfd 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -46,17 +46,17 @@ Grid::load (Inkscape::Extension::Extension */*module*/) namespace { -Glib::ustring build_lines(int axis, NR::Rect bounding_area, +Glib::ustring build_lines(int axis, Geom::Rect bounding_area, float offset, float spacing) { - NR::Point point_offset(0.0, 0.0); + Geom::Point point_offset(0.0, 0.0); point_offset[axis] = offset; SVG::PathString path_data; - for (NR::Point start_point = bounding_area.min(); + for (Geom::Point start_point = bounding_area.min(); start_point[axis] + offset <= (bounding_area.max())[axis]; start_point[axis] += spacing) { - NR::Point end_point = start_point; + Geom::Point end_point = start_point; end_point[1-axis] = (bounding_area.max())[1-axis]; path_data.moveTo(start_point + point_offset) @@ -78,22 +78,21 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc { Inkscape::Selection * selection = ((SPDesktop *)document)->selection; - NR::Rect bounding_area = NR::Rect(NR::Point(0,0), NR::Point(100,100)); + Geom::Rect bounding_area = Geom::Rect(Geom::Point(0,0), Geom::Point(100,100)); if (selection->isEmpty()) { /* get page size */ SPDocument * doc = document->doc(); - bounding_area = NR::Rect(NR::Point(0,0), - NR::Point(sp_document_width(doc), - sp_document_height(doc))); + bounding_area = Geom::Rect( Geom::Point(0,0), + Geom::Point(sp_document_width(doc), sp_document_height(doc)) ); } else { boost::optional bounds = selection->bounds(); if (bounds) { - bounding_area = *bounds; + bounding_area = to_2geom(*bounds); } gdouble doc_height = sp_document_height(document->doc()); - NR::Rect temprec = NR::Rect(NR::Point(bounding_area.min()[NR::X], doc_height - bounding_area.min()[NR::Y]), - NR::Point(bounding_area.max()[NR::X], doc_height - bounding_area.max()[NR::Y])); + Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]), + Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y])); bounding_area = temprec; } diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index eeda6f187..84e493afa 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -150,7 +150,7 @@ PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc) os << "\\begin{pspicture}(" << sp_document_width(doc) << "," << sp_document_height(doc) << ")\n"; } - m_tr_stack.push( NR::scale(1, -1) * NR::translate(0, sp_document_height(doc))); + m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, sp_document_height(doc))); return fprintf(_stream, "%s", os.str().c_str()); } @@ -173,12 +173,12 @@ PrintLatex::finish (Inkscape::Extension::Print *mod) } unsigned int -PrintLatex::bind(Inkscape::Extension::Print *mod, NR::Matrix const *transform, float opacity) +PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Matrix const *transform, float opacity) { - NR::Matrix tr = *transform; + Geom::Matrix tr = *transform; if(m_tr_stack.size()){ - NR::Matrix tr_top = m_tr_stack.top(); + Geom::Matrix tr_top = m_tr_stack.top(); m_tr_stack.push(tr * tr_top); }else m_tr_stack.push(tr); @@ -203,7 +203,7 @@ unsigned int PrintLatex::comment (Inkscape::Extension::Print * module, unsigned int PrintLatex::fill(Inkscape::Extension::Print *mod, - Geom::PathVector const &pathv, NR::Matrix const *transform, SPStyle const *style, + Geom::PathVector const &pathv, Geom::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -230,7 +230,7 @@ PrintLatex::fill(Inkscape::Extension::Print *mod, } unsigned int -PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, const NR::Matrix *transform, const SPStyle *style, +PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, const Geom::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -238,8 +238,8 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pat if (style->stroke.isColor()) { Inkscape::SVGOStringStream os; float rgb[3]; - NR::Matrix tr_stack = m_tr_stack.top(); - double const scale = expansion(tr_stack); + Geom::Matrix tr_stack = m_tr_stack.top(); + double const scale = tr_stack.descrim(); os.setf(std::ios::fixed); sp_color_get_rgb_floatv(&style->stroke.value.color, rgb); @@ -274,13 +274,13 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pat // FIXME: why is 'transform' argument not used? void -PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const NR::Matrix * /*transform*/) +PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Matrix * /*transform*/) { if (pathv_in.empty()) return; -// NR::Matrix tf=*transform; // why was this here? - NR::Matrix tf_stack=m_tr_stack.top(); // and why is transform argument not used? +// Geom::Matrix tf=*transform; // why was this here? + Geom::Matrix tf_stack=m_tr_stack.top(); // and why is transform argument not used? Geom::PathVector pathv = pathv_in * tf_stack; // generates new path, which is a bit slow, but this doesn't have to be performance optimized os << "\\newpath\n"; diff --git a/src/extension/internal/latex-pstricks.h b/src/extension/internal/latex-pstricks.h index 3ce54d4c2..a33e169e8 100644 --- a/src/extension/internal/latex-pstricks.h +++ b/src/extension/internal/latex-pstricks.h @@ -31,9 +31,9 @@ class PrintLatex : public Inkscape::Extension::Implementation::Implementation { float _height; FILE * _stream; - std::stack m_tr_stack; + std::stack m_tr_stack; - void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const NR::Matrix * /*transform*/); + void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Matrix * /*transform*/); void print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c ); public: @@ -47,12 +47,12 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); - virtual unsigned int fill (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const NR::Matrix *ctm, const SPStyle *style, + virtual unsigned int fill (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); - virtual unsigned int stroke (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const NR::Matrix *transform, const SPStyle *style, + virtual unsigned int stroke (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); bool textToPath (Inkscape::Extension::Print * ext); diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 8ad9b5031..016906289 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -258,7 +258,7 @@ private: * NOTE: * This class is ported almost verbatim from the public domain * JAMA Matrix package. It is modified to handle only 3x3 matrices - * and our NR::Matrix affine transform class. We give full + * and our Geom::Matrix affine transform class. We give full * attribution to them, along with many thanks. JAMA can be found at: * http://math.nist.gov/javanumerics/jama * @@ -920,10 +920,10 @@ static Glib::ustring getExtension(const Glib::ustring &fname) } -static Glib::ustring formatTransform(NR::Matrix &tf) +static Glib::ustring formatTransform(Geom::Matrix &tf) { Glib::ustring str; - if (!tf.test_identity()) + if (!tf.isIdentity()) { StringOutputStream outs; OutputStreamWriter out(outs); @@ -942,16 +942,16 @@ static Glib::ustring formatTransform(NR::Matrix &tf) * Get the general transform from SVG pixels to * ODF cm */ -static NR::Matrix getODFTransform(const SPItem *item) +static Geom::Matrix getODFTransform(const SPItem *item) { //### Get SVG-to-ODF transform - NR::Matrix tf (sp_item_i2d_affine(item)); + Geom::Matrix tf (sp_item_i2d_affine(item)); //Flip Y into document coordinates double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT); - NR::Matrix doc2dt_tf = NR::Matrix(NR::scale(1.0, -1.0)); - doc2dt_tf = doc2dt_tf * NR::Matrix(NR::translate(0, doc_height)); + Geom::Matrix doc2dt_tf = Geom::Matrix(Geom::Scale(1.0, -1.0)); + doc2dt_tf = doc2dt_tf * Geom::Matrix(Geom::Translate(0, doc_height)); tf = tf * doc2dt_tf; - tf = tf * NR::Matrix(NR::scale(pxToCm)); + tf = tf * Geom::Matrix(Geom::Scale(pxToCm)); return tf; } @@ -962,15 +962,17 @@ static NR::Matrix getODFTransform(const SPItem *item) * Get the bounding box of an item, as mapped onto * an ODF document, in cm. */ -static boost::optional getODFBoundingBox(const SPItem *item) +static boost::optional getODFBoundingBox(const SPItem *item) { - boost::optional bbox = sp_item_bbox_desktop((SPItem *)item); - if (bbox) { + boost::optional bbox_temp = sp_item_bbox_desktop((SPItem *)item); + boost::optional bbox; + if (bbox_temp) { + bbox = to_2geom(*bbox_temp); double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT); - NR::Matrix doc2dt_tf = NR::Matrix(NR::scale(1.0, -1.0)); - doc2dt_tf = doc2dt_tf * NR::Matrix(NR::translate(0, doc_height)); + Geom::Matrix doc2dt_tf = Geom::Matrix(Geom::Scale(1.0, -1.0)); + doc2dt_tf = doc2dt_tf * Geom::Matrix(Geom::Translate(0, doc_height)); bbox = *bbox * doc2dt_tf; - bbox = *bbox * NR::Matrix(NR::scale(pxToCm)); + bbox = *bbox * Geom::Matrix(Geom::Scale(pxToCm)); } return bbox; } @@ -981,11 +983,11 @@ static boost::optional getODFBoundingBox(const SPItem *item) * Get the transform for an item, correcting for * handedness reversal */ -static NR::Matrix getODFItemTransform(const SPItem *item) +static Geom::Matrix getODFItemTransform(const SPItem *item) { - NR::Matrix itemTransform = NR::Matrix(NR::scale(1, -1)); - itemTransform = itemTransform * item->transform; - itemTransform = itemTransform * NR::Matrix(NR::scale(1, -1)); + Geom::Matrix itemTransform (Geom::Scale(1, -1)); + itemTransform = itemTransform * (Geom::Matrix)item->transform; + itemTransform = itemTransform * Geom::Scale(1, -1); return itemTransform; } @@ -994,7 +996,7 @@ static NR::Matrix getODFItemTransform(const SPItem *item) /** * Get some fun facts from the transform */ -static void analyzeTransform(NR::Matrix &tf, +static void analyzeTransform(Geom::Matrix &tf, double &rotate, double &/*xskew*/, double &/*yskew*/, double &xscale, double &yscale) { @@ -1084,7 +1086,7 @@ OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node) } SPItem *item = SP_ITEM(reprobj); //### Get SVG-to-ODF transform - NR::Matrix tf = getODFTransform(item); + Geom::Matrix tf = getODFTransform(item); if (nodeName == "image" || nodeName == "svg:image") { @@ -1635,7 +1637,7 @@ bool OdfOutput::processStyle(Writer &outs, SPItem *item, bool OdfOutput::processGradient(Writer &outs, SPItem *item, - const Glib::ustring &id, NR::Matrix &/*tf*/) + const Glib::ustring &id, Geom::Matrix &/*tf*/) { if (!item) return false; @@ -1673,14 +1675,14 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item, gi.style = "linear"; SPLinearGradient *linGrad = SP_LINEARGRADIENT(gradient); /* - NR::Point p1(linGrad->x1.value, linGrad->y1.value); + Geom::Point p1(linGrad->x1.value, linGrad->y1.value); p1 = p1 * tf; - gi.x1 = p1[NR::X]; - gi.y1 = p1[NR::Y]; - NR::Point p2(linGrad->x2.value, linGrad->y2.value); + gi.x1 = p1[Geom::X]; + gi.y1 = p1[Geom::Y]; + Geom::Point p2(linGrad->x2.value, linGrad->y2.value); p2 = p2 * tf; - gi.x2 = p2[NR::X]; - gi.y2 = p2[NR::Y]; + gi.x2 = p2[Geom::X]; + gi.y2 = p2[Geom::Y]; */ gi.x1 = linGrad->x1.value; gi.y1 = linGrad->y1.value; @@ -1861,18 +1863,18 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, Glib::ustring id = getAttribute(node, "id"); //### Get SVG-to-ODF transform - NR::Matrix tf = getODFTransform(item); + Geom::Matrix tf = getODFTransform(item); //### Get ODF bounding box params for item - boost::optional bbox = getODFBoundingBox(item); + boost::optional bbox = getODFBoundingBox(item); if (!bbox) { return true; } - double bbox_x = bbox->min()[NR::X]; - double bbox_y = bbox->min()[NR::Y]; - double bbox_width = bbox->extent(NR::X); - double bbox_height = bbox->extent(NR::Y); + double bbox_x = bbox->min()[Geom::X]; + double bbox_y = bbox->min()[Geom::Y]; + double bbox_width = (*bbox)[Geom::X].extent(); + double bbox_height = (*bbox)[Geom::Y].extent(); double rotate; double xskew; @@ -1948,16 +1950,16 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, double iwidth = img->width.value; double iheight = img->height.value; - NR::Rect ibbox(NR::Point(ix, iy), NR::Point(ix+iwidth, iy+iheight)); + Geom::Rect ibbox(Geom::Point(ix, iy), Geom::Point(ix+iwidth, iy+iheight)); ibbox = ibbox * tf; - ix = ibbox.min()[NR::X]; - iy = ibbox.min()[NR::Y]; - //iwidth = ibbox.max()[NR::X] - ibbox.min()[NR::X]; - //iheight = ibbox.max()[NR::Y] - ibbox.min()[NR::Y]; + ix = ibbox.min()[Geom::X]; + iy = ibbox.min()[Geom::Y]; + //iwidth = ibbox.max()[Geom::X] - ibbox.min()[Geom::X]; + //iheight = ibbox.max()[Geom::Y] - ibbox.min()[Geom::Y]; iwidth = xscale * iwidth; iheight = yscale * iheight; - NR::Matrix itemTransform = getODFItemTransform(item); + Geom::Matrix itemTransform = getODFItemTransform(item); Glib::ustring itemTransformString = formatTransform(itemTransform); diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h index a12ab4b02..8d38e530f 100644 --- a/src/extension/internal/odf.h +++ b/src/extension/internal/odf.h @@ -316,7 +316,7 @@ private: bool processStyle(Writer &outs, SPItem *item, const Glib::ustring &id); bool processGradient(Writer &outs, SPItem *item, - const Glib::ustring &id, NR::Matrix &tf); + const Glib::ustring &id, Geom::Matrix &tf); bool writeStyleHeader(Writer &outs); diff --git a/src/extension/internal/pdf-cairo.cpp b/src/extension/internal/pdf-cairo.cpp index 2b3c93824..6c2b2ed62 100644 --- a/src/extension/internal/pdf-cairo.cpp +++ b/src/extension/internal/pdf-cairo.cpp @@ -327,7 +327,7 @@ PrintCairoPDF::begin(Inkscape::Extension::Print *mod, SPDocument *doc) bool pageBoundingBox = mod->get_param_bool("pageBoundingBox"); SPItem* doc_item = SP_ITEM(mod->base); // printf("Page Bounding Box: %s\n", pageBoundingBox ? "TRUE" : "FALSE"); - NR::Matrix t (NR::identity()); + Geom::Matrix t (Geom::identity()); if (pageBoundingBox) { d.x0 = d.y0 = 0; d.x1 = _width; @@ -350,7 +350,7 @@ PrintCairoPDF::begin(Inkscape::Extension::Print *mod, SPDocument *doc) // complete transform, including doc_item's own transform t = sp_item_i2doc_affine (doc_item); // subreact doc_item's transform (comes first) from it - t = NR::Matrix(doc_item->transform).inverse() * t; + t = Geom::Matrix(doc_item->transform).inverse() * t; // create cairo context pdf_surface = cairo_pdf_surface_create_for_stream(Inkscape::Extension::Internal::_write_callback, _stream, d.x1-d.x0, d.y1-d.y0); @@ -402,7 +402,7 @@ PrintCairoPDF::finish(Inkscape::Extension::Print *mod) } unsigned int -PrintCairoPDF::bind(Inkscape::Extension::Print *mod, NR::Matrix const *transform, float opacity) +PrintCairoPDF::bind(Inkscape::Extension::Print *mod, Geom::Matrix const *transform, float opacity) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. if (_bitmap) return 0; @@ -465,17 +465,17 @@ PrintCairoPDF::create_pattern_for_paint(SPPaintServer const *const paintserver, sp_gradient_ensure_vector(SP_GRADIENT(lg)); // when exporting from commandline, vector is not built - NR::Point p1 (lg->x1.computed, lg->y1.computed); - NR::Point p2 (lg->x2.computed, lg->y2.computed); + Geom::Point p1 (lg->x1.computed, lg->y1.computed); + Geom::Point p2 (lg->x2.computed, lg->y2.computed); if (pbox && SP_GRADIENT(lg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { // convert to userspace - NR::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + Geom::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); p1 *= bbox2user; p2 *= bbox2user; } // create linear gradient pattern - pattern = cairo_pattern_create_linear(p1[NR::X], p1[NR::Y], p2[NR::X], p2[NR::Y]); + pattern = cairo_pattern_create_linear(p1[Geom::X], p1[Geom::Y], p2[Geom::X], p2[Geom::Y]); // add stops for (gint i = 0; unsigned(i) < lg->vector.stops.size(); i++) { @@ -489,21 +489,21 @@ PrintCairoPDF::create_pattern_for_paint(SPPaintServer const *const paintserver, sp_gradient_ensure_vector(SP_GRADIENT(rg)); // when exporting from commandline, vector is not built - NR::Point c (rg->cx.computed, rg->cy.computed); - NR::Point f (rg->fx.computed, rg->fy.computed); + Geom::Point c (rg->cx.computed, rg->cy.computed); + Geom::Point f (rg->fx.computed, rg->fy.computed); double r = rg->r.computed; - NR::Coord const df = hypot(f[NR::X] - c[NR::X], f[NR::Y] - c[NR::Y]); + Geom::Coord const df = hypot(f[Geom::X] - c[Geom::X], f[Geom::Y] - c[Geom::Y]); if (df >= r) { - f[NR::X] = c[NR::X] + (f[NR::X] - c[NR::X] ) * r / (float) df; - f[NR::Y] = c[NR::Y] + (f[NR::Y] - c[NR::Y] ) * r / (float) df; + f[Geom::X] = c[Geom::X] + (f[Geom::X] - c[Geom::X] ) * r / (float) df; + f[Geom::Y] = c[Geom::Y] + (f[Geom::Y] - c[Geom::Y] ) * r / (float) df; } if (pbox && SP_GRADIENT(rg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) apply_bbox2user = true; // create radial gradient pattern - pattern = cairo_pattern_create_radial(f[NR::X], f[NR::Y], 0, c[NR::X], c[NR::Y], r); + pattern = cairo_pattern_create_radial(f[Geom::X], f[Geom::Y], 0, c[Geom::X], c[Geom::Y], r); // add stops for (gint i = 0; unsigned(i) < rg->vector.stops.size(); i++) { @@ -583,7 +583,7 @@ PrintCairoPDF::print_fill_style(cairo_t *cr, SPStyle const *const style, NRRect } unsigned int -PrintCairoPDF::fill(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *const style, +PrintCairoPDF::fill(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *const style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -686,7 +686,7 @@ PrintCairoPDF::print_stroke_style(cairo_t *cr, SPStyle const *style, NRRect cons } unsigned int -PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *style, +PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -712,7 +712,7 @@ PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, Geom::PathVector const &p unsigned int PrintCairoPDF::image(Inkscape::Extension::Print *mod, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *transform, SPStyle const *style) + Geom::Matrix const *transform, SPStyle const *style) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. if (_bitmap) return 0; @@ -786,8 +786,8 @@ PrintCairoPDF::image(Inkscape::Extension::Print *mod, guchar *px, unsigned int w #ifndef RENDER_WITH_PANGO_CAIRO -NR::Point -PrintCairoPDF::draw_glyphs(cairo_t *cr, NR::Point p, PangoFont *font, PangoGlyphString *glyph_string, +Geom::Point +PrintCairoPDF::draw_glyphs(cairo_t *cr, Geom::Point p, PangoFont *font, PangoGlyphString *glyph_string, bool vertical, bool stroke) { cairo_glyph_t glyph_array[GLYPH_ARRAY_SIZE]; @@ -808,8 +808,8 @@ PrintCairoPDF::draw_glyphs(cairo_t *cr, NR::Point p, PangoFont *font, PangoGlyph } glyphs[i - num_invalid_glyphs].index = info->glyph; - glyphs[i - num_invalid_glyphs].x = p[NR::X] + (x_offset + info->geometry.x_offset)/PANGO_SCALE; - glyphs[i - num_invalid_glyphs].y = p[NR::Y] + (y_offset + info->geometry.y_offset)/PANGO_SCALE; + glyphs[i - num_invalid_glyphs].x = p[Geom::X] + (x_offset + info->geometry.x_offset)/PANGO_SCALE; + glyphs[i - num_invalid_glyphs].y = p[Geom::Y] + (y_offset + info->geometry.y_offset)/PANGO_SCALE; if (vertical) { cairo_text_extents_t extents; @@ -828,14 +828,14 @@ PrintCairoPDF::draw_glyphs(cairo_t *cr, NR::Point p, PangoFont *font, PangoGlyph if (glyph_string->num_glyphs > GLYPH_ARRAY_SIZE) g_free(glyphs); - return NR::Point(x_offset, y_offset); + return Geom::Point(x_offset, y_offset); } #endif unsigned int -PrintCairoPDF::text(Inkscape::Extension::Print *mod, char const *text, NR::Point p, +PrintCairoPDF::text(Inkscape::Extension::Print *mod, char const *text, Geom::Point p, SPStyle const *const style) { bool dirty_pattern = false; @@ -923,7 +923,7 @@ PrintCairoPDF::text(Inkscape::Extension::Print *mod, char const *text, NR::Point print_fill_style(cr, style, NULL); #ifndef RENDER_WITH_PANGO_CAIRO - NR::Point cursor(_last_tx, _last_ty); + Geom::Point cursor(_last_tx, _last_ty); for (GSList *tmpList = line->runs; tmpList && tmpList->data; tmpList = tmpList->next) { PangoLayoutRun *run = (PangoLayoutRun *)tmpList->data; cursor += draw_glyphs(cr, cursor, run->item->analysis.font, run->glyphs, dirty_pattern, false) / PANGO_SCALE; @@ -951,7 +951,7 @@ PrintCairoPDF::text(Inkscape::Extension::Print *mod, char const *text, NR::Point // paint stroke #ifndef RENDER_WITH_PANGO_CAIRO - NR::Point cursor(_last_tx, _last_ty); + Geom::Point cursor(_last_tx, _last_ty); for (GSList *tmpList = line->runs; tmpList && tmpList->data; tmpList = tmpList->next) { PangoLayoutRun *run = (PangoLayoutRun *)tmpList->data; cursor += draw_glyphs(cr, cursor, run->item->analysis.font, run->glyphs, dirty_pattern, true) / PANGO_SCALE; diff --git a/src/extension/internal/pdf-cairo.h b/src/extension/internal/pdf-cairo.h index c309add15..2b81fa30e 100644 --- a/src/extension/internal/pdf-cairo.h +++ b/src/extension/internal/pdf-cairo.h @@ -55,7 +55,7 @@ class PrintCairoPDF : public Inkscape::Extension::Implementation::Implementation void print_stroke_style(cairo_t *cr, SPStyle const *style, NRRect const *pbox); #ifndef RENDER_WITH_PANGO_CAIRO - NR::Point draw_glyphs(cairo_t *cr, NR::Point p, PangoFont *font, PangoGlyphString *glyph_string, + Geom::Point draw_glyphs(cairo_t *cr, Geom::Point p, PangoFont *font, PangoGlyphString *glyph_string, bool vertical, bool stroke); #endif @@ -73,17 +73,17 @@ public: virtual unsigned int finish(Inkscape::Extension::Print *module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment); - virtual unsigned int fill(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *style, + virtual unsigned int fill(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); - virtual unsigned int stroke(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, NR::Matrix const *transform, SPStyle const *style, + virtual unsigned int stroke(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, Geom::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *transform, SPStyle const *style); + Geom::Matrix const *transform, SPStyle const *style); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, - NR::Point p, SPStyle const *style); + Geom::Point p, SPStyle const *style); bool textToPath(Inkscape::Extension::Print *ext); static void init(void); diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 718dfbcb0..e28264eff 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -233,7 +233,7 @@ static gchar *svgConvertGfxRGB(GfxRGB *color) { static void svgSetTransform(Inkscape::XML::Node *node, double c0, double c1, double c2, double c3, double c4, double c5) { - NR::Matrix matrix(c0, c1, c2, c3, c4, c5); + Geom::Matrix matrix(c0, c1, c2, c3, c4, c5); gchar *transform_text = sp_svg_transform_write(matrix); node->setAttribute("transform", transform_text); g_free(transform_text); @@ -530,7 +530,7 @@ void SvgBuilder::setClipPath(GfxState *state, bool even_odd) { * \return true on success; false on invalid transformation */ bool SvgBuilder::getTransform(double *transform) { - NR::Matrix svd; + Geom::Matrix svd; gchar const *tr = _container->attribute("transform"); bool valid = sp_svg_transform_read(tr, &svd); if (valid) { @@ -619,7 +619,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern, Inkscape::XML::Node *pattern_node = _xml_doc->createElement("svg:pattern"); // Set pattern transform matrix double *p2u = tiling_pattern->getMatrix(); - NR::Matrix pat_matrix(p2u[0], p2u[1], p2u[2], p2u[3], p2u[4], p2u[5]); + Geom::Matrix pat_matrix(p2u[0], p2u[1], p2u[2], p2u[3], p2u[4], p2u[5]); gchar *transform_text = sp_svg_transform_write(pat_matrix); pattern_node->setAttribute("patternTransform", transform_text); g_free(transform_text); @@ -717,10 +717,10 @@ gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for gradient->setAttribute("gradientUnits", "userSpaceOnUse"); // If needed, flip the gradient transform around the y axis if (matrix) { - NR::Matrix pat_matrix(matrix[0], matrix[1], matrix[2], matrix[3], + Geom::Matrix pat_matrix(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); if ( !for_shading && _is_top_level ) { - NR::Matrix flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * PT_PER_PX); + Geom::Matrix flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * PT_PER_PX); pat_matrix *= flip; } gchar *transform_text = sp_svg_transform_write(pat_matrix); @@ -1046,7 +1046,7 @@ void SvgBuilder::updateTextShift(GfxState *state, double shift) { * \brief Updates current text position */ void SvgBuilder::updateTextPosition(double tx, double ty) { - NR::Point new_position(tx, ty); + Geom::Point new_position(tx, ty); _text_position = new_position; } @@ -1066,7 +1066,7 @@ void SvgBuilder::updateTextMatrix(GfxState *state) { max_scale = h_scale; } // Calculate new text matrix - NR::Matrix new_text_matrix(text_matrix[0] * state->getHorizScaling(), + Geom::Matrix new_text_matrix(text_matrix[0] * state->getHorizScaling(), text_matrix[1] * state->getHorizScaling(), -text_matrix[2], -text_matrix[3], 0.0, 0.0); @@ -1101,7 +1101,7 @@ void SvgBuilder::_flushText() { Inkscape::XML::Node *text_node = _xml_doc->createElement("svg:text"); // Set text matrix - NR::Matrix text_transform(_text_matrix); + Geom::Matrix text_transform(_text_matrix); text_transform[4] = first_glyph.position[0]; text_transform[5] = first_glyph.position[1]; gchar *transform = sp_svg_transform_write(text_transform); @@ -1110,7 +1110,7 @@ void SvgBuilder::_flushText() { bool new_tspan = true; bool same_coords[2] = {true, true}; - NR::Point last_delta_pos; + Geom::Point last_delta_pos; unsigned int glyphs_in_a_row = 0; Inkscape::XML::Node *tspan_node = NULL; Glib::ustring x_coords; @@ -1197,7 +1197,7 @@ void SvgBuilder::_flushText() { } } // Append the coordinates to their respective strings - NR::Point delta_pos( glyph.text_position - first_glyph.text_position ); + Geom::Point delta_pos( glyph.text_position - first_glyph.text_position ); delta_pos[1] += glyph.rise; delta_pos[1] *= -1.0; // flip it delta_pos *= _font_scaling; @@ -1245,25 +1245,25 @@ void SvgBuilder::addChar(GfxState *state, double x, double y, bool is_space = ( uLen == 1 && u[0] == 32 ); // Skip beginning space if ( is_space && _glyphs.size() < 1 ) { - NR::Point delta(dx, dy); + Geom::Point delta(dx, dy); _text_position += delta; return; } // Allow only one space in a row if ( is_space && _glyphs[_glyphs.size() - 1].code_size == 1 && _glyphs[_glyphs.size() - 1].code[0] == 32 ) { - NR::Point delta(dx, dy); + Geom::Point delta(dx, dy); _text_position += delta; return; } SvgGlyph new_glyph; new_glyph.is_space = is_space; - new_glyph.position = NR::Point( x - originX, y - originY ); + new_glyph.position = Geom::Point( x - originX, y - originY ); new_glyph.text_position = _text_position; new_glyph.dx = dx; new_glyph.dy = dy; - NR::Point delta(dx, dy); + Geom::Point delta(dx, dy); _text_position += delta; // Convert the character to UTF-8 since that's our SVG document's encoding @@ -1631,7 +1631,7 @@ void SvgBuilder::addMaskedImage(GfxState *state, Stream *str, int width, int hei mask_image_node->setAttribute("transform", NULL); mask_node->appendChild(mask_image_node); // Scale the mask to the size of the image - NR::Matrix mask_transform((double)width, 0.0, 0.0, (double)height, 0.0, 0.0); + Geom::Matrix mask_transform((double)width, 0.0, 0.0, (double)height, 0.0, 0.0); gchar *transform_text = sp_svg_transform_write(mask_transform); mask_node->setAttribute("maskTransform", transform_text); g_free(transform_text); diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index 4a57d5bb9..28f7e1be3 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -73,8 +73,8 @@ struct SvgGraphicsState { * to the document yet. */ struct SvgGlyph { - NR::Point position; // Absolute glyph coords - NR::Point text_position; // Absolute glyph coords in text space + Geom::Point position; // Absolute glyph coords + Geom::Point text_position; // Absolute glyph coords in text space double dx, dy; // Advance values double rise; // Text rise parameter char code[8]; // UTF-8 coded character @@ -209,8 +209,8 @@ private: char *_font_specification; double _font_scaling; bool _need_font_update; - NR::Matrix _text_matrix; - NR::Point _text_position; + Geom::Matrix _text_matrix; + Geom::Point _text_position; std::vector _glyphs; // Added characters bool _in_text_object; // Whether we are inside a text object bool _invalidated_style; diff --git a/src/extension/internal/ps.cpp b/src/extension/internal/ps.cpp index 15b0bd8f4..97582bd13 100644 --- a/src/extension/internal/ps.cpp +++ b/src/extension/internal/ps.cpp @@ -586,7 +586,7 @@ PrintPS::finish(Inkscape::Extension::Print *mod) memset(px, 0xff, 4 * width * 64); nr_arena_item_invoke_render(NULL, mod->root, &bbox, &pb, 0); /* Blitter goes here */ - NR::Matrix imgt; + Geom::Matrix imgt; imgt[0] = (bbox.x1 - bbox.x0) / dots_per_pt; imgt[1] = 0.0; imgt[2] = 0.0; @@ -633,7 +633,7 @@ PrintPS::finish(Inkscape::Extension::Print *mod) } unsigned int -PrintPS::bind(Inkscape::Extension::Print */*mod*/, NR::Matrix const *transform, float /*opacity*/) +PrintPS::bind(Inkscape::Extension::Print */*mod*/, Geom::Matrix const *transform, float /*opacity*/) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. if (_bitmap) return 0; @@ -687,17 +687,17 @@ PrintPS::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRRe if (SP_IS_LINEARGRADIENT(SP_STYLE_FILL_SERVER(style))) { SPLinearGradient *lg = SP_LINEARGRADIENT(SP_STYLE_FILL_SERVER(style)); - NR::Point p1 (lg->x1.computed, lg->y1.computed); - NR::Point p2 (lg->x2.computed, lg->y2.computed); + Geom::Point p1 (lg->x1.computed, lg->y1.computed); + Geom::Point p2 (lg->x2.computed, lg->y2.computed); if (pbox && SP_GRADIENT(lg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { // convert to userspace - NR::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + Geom::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); p1 *= bbox2user; p2 *= bbox2user; } os << "<<\n/ShadingType 2\n/ColorSpace /DeviceRGB\n"; - os << "/Coords [" << p1[NR::X] << " " << p1[NR::Y] << " " << p2[NR::X] << " " << p2[NR::Y] <<"]\n"; + os << "/Coords [" << p1[Geom::X] << " " << p1[Geom::Y] << " " << p2[Geom::X] << " " << p2[Geom::Y] <<"]\n"; os << "/Extend [true true]\n"; os << "/Domain [0 1]\n"; os << "/Function <<\n/FunctionType 3\n/Functions\n[\n"; @@ -728,21 +728,21 @@ PrintPS::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRRe } else if (SP_IS_RADIALGRADIENT(SP_STYLE_FILL_SERVER(style))) { SPRadialGradient *rg = SP_RADIALGRADIENT(SP_STYLE_FILL_SERVER(style)); - NR::Point c(rg->cx.computed, rg->cy.computed); - NR::Point f(rg->fx.computed, rg->fy.computed); + Geom::Point c(rg->cx.computed, rg->cy.computed); + Geom::Point f(rg->fx.computed, rg->fy.computed); double r = rg->r.computed; if (pbox && SP_GRADIENT(rg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { // convert to userspace - NR::Matrix const bbox2user(pbox->x1 - pbox->x0, 0, + Geom::Matrix const bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); c *= bbox2user; f *= bbox2user; - r *= NR::expansion(bbox2user); + r *= bbox2user.descrim(); } os << "<<\n/ShadingType 3\n/ColorSpace /DeviceRGB\n"; - os << "/Coords ["<< f[NR::X] <<" "<< f[NR::Y] <<" 0 "<< c[NR::X] <<" "<< c[NR::Y] <<" "<< r <<"]\n"; + os << "/Coords ["<< f[Geom::X] <<" "<< f[Geom::Y] <<" 0 "<< c[Geom::X] <<" "<< c[Geom::Y] <<" "<< r <<"]\n"; os << "/Extend [true true]\n"; os << "/Domain [0 1]\n"; os << "/Function <<\n/FunctionType 3\n/Functions\n[\n"; @@ -817,7 +817,7 @@ PrintPS::print_stroke_style(SVGOStringStream &os, SPStyle const *style) unsigned int -PrintPS::fill(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *const style, +PrintPS::fill(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *const style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -883,7 +883,7 @@ PrintPS::fill(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, NR unsigned int -PrintPS::stroke(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *style, +PrintPS::stroke(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -906,7 +906,7 @@ PrintPS::stroke(Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, unsigned int PrintPS::image(Inkscape::Extension::Print *mod, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *transform, SPStyle const *style) + Geom::Matrix const *transform, SPStyle const *style) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. if (_bitmap) return 0; @@ -1261,7 +1261,7 @@ void PrintPS::print_glyphlist(SVGOStringStream &os, font_instance* font, Glib::u } unsigned int -PrintPS::text(Inkscape::Extension::Print *mod, char const *text, NR::Point p, +PrintPS::text(Inkscape::Extension::Print *mod, char const *text, Geom::Point p, SPStyle const *const style) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -1403,7 +1403,7 @@ PrintPS::text(Inkscape::Extension::Print *mod, char const *text, NR::Point p, // (text is black) for some reason. os << "newpath\n"; - os << p[NR::X] << " " << p[NR::Y] << " moveto\n"; + os << p[Geom::X] << " " << p[Geom::Y] << " moveto\n"; os << "("; if(font_embedded) print_glyphlist(os, tf, s); else os << escaped_text.str(); @@ -1417,7 +1417,7 @@ PrintPS::text(Inkscape::Extension::Print *mod, char const *text, NR::Point p, // paint stroke os << "newpath\n"; - os << p[NR::X] << " " << p[NR::Y] << " moveto\n"; + os << p[Geom::X] << " " << p[Geom::Y] << " moveto\n"; os << "("; if(font_embedded) print_glyphlist(os, tf, s); else os << escaped_text.str(); @@ -1650,7 +1650,7 @@ PrintPS::ascii85_done(SVGOStringStream &os) unsigned int PrintPS::print_image(FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs, - NR::Matrix const *transform) + Geom::Matrix const *transform) { Inkscape::SVGOStringStream os; diff --git a/src/extension/internal/ps.h b/src/extension/internal/ps.h index 179779e25..b872aa425 100644 --- a/src/extension/internal/ps.h +++ b/src/extension/internal/ps.h @@ -60,7 +60,7 @@ class PrintPS : public Inkscape::Extension::Implementation::Implementation { void print_glyphlist(SVGOStringStream &os, font_instance* font, Glib::ustring unistring); unsigned int print_image(FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs, - NR::Matrix const *transform); + Geom::Matrix const *transform); void compress_packbits(int nin, guchar *src, int *nout, guchar *dst); /* ASCII 85 variables */ @@ -89,17 +89,17 @@ public: virtual unsigned int finish(Inkscape::Extension::Print *module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment); - virtual unsigned int fill(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *style, + virtual unsigned int fill(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); - virtual unsigned int stroke(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, NR::Matrix const *transform, SPStyle const *style, + virtual unsigned int stroke(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, Geom::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *transform, SPStyle const *style); + Geom::Matrix const *transform, SPStyle const *style); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, - NR::Point p, SPStyle const *style); + Geom::Point p, SPStyle const *style); bool textToPath(Inkscape::Extension::Print *ext); static void init(void); diff --git a/src/extension/internal/win32.cpp b/src/extension/internal/win32.cpp index 1d242d80d..85f502f00 100644 --- a/src/extension/internal/win32.cpp +++ b/src/extension/internal/win32.cpp @@ -40,37 +40,37 @@ static unsigned int SPWin32Modal = FALSE; static void my_gdk_event_handler (GdkEvent *event) { - if (SPWin32Modal) { - /* Win32 widget is modal, filter events */ - switch (event->type) { - case GDK_NOTHING: - case GDK_DELETE: - case GDK_SCROLL: - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - case GDK_DRAG_STATUS: - case GDK_DRAG_ENTER: - case GDK_DRAG_LEAVE: - case GDK_DRAG_MOTION: - case GDK_DROP_START: - case GDK_DROP_FINISHED: - return; - break; - default: - break; - } - } - gtk_main_do_event (event); + if (SPWin32Modal) { + /* Win32 widget is modal, filter events */ + switch (event->type) { + case GDK_NOTHING: + case GDK_DELETE: + case GDK_SCROLL: + case GDK_BUTTON_PRESS: + case GDK_2BUTTON_PRESS: + case GDK_3BUTTON_PRESS: + case GDK_BUTTON_RELEASE: + case GDK_KEY_PRESS: + case GDK_KEY_RELEASE: + case GDK_DRAG_STATUS: + case GDK_DRAG_ENTER: + case GDK_DRAG_LEAVE: + case GDK_DRAG_MOTION: + case GDK_DROP_START: + case GDK_DROP_FINISHED: + return; + break; + default: + break; + } + } + gtk_main_do_event (event); } void PrintWin32::main_init (int argc, char **argv, const char *name) { - gdk_event_handler_set ((GdkEventFunc) my_gdk_event_handler, NULL, NULL); + gdk_event_handler_set ((GdkEventFunc) my_gdk_event_handler, NULL, NULL); } void @@ -87,11 +87,11 @@ PrintWin32::finish (void) static VOID CALLBACK my_timer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { - int cdown = 0; - while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) { - gtk_main_iteration_do (FALSE); - } - gtk_main_iteration_do (FALSE); + int cdown = 0; + while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) { + gtk_main_iteration_do (FALSE); + } + gtk_main_iteration_do (FALSE); } @@ -100,28 +100,28 @@ my_timer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) gboolean PrintWin32::is_os_wide() { - static gboolean initialized = FALSE; - static gboolean is_wide = FALSE; - static OSVERSIONINFOA osver; - - if ( !initialized ) - { - BOOL result; - - initialized = TRUE; - - memset (&osver, 0, sizeof(OSVERSIONINFOA)); - osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); - result = GetVersionExA (&osver); - if (result) - { - if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) - is_wide = TRUE; - } - // If we can't even call to get the version, fall back to ANSI API - } - - return is_wide; + static gboolean initialized = FALSE; + static gboolean is_wide = FALSE; + static OSVERSIONINFOA osver; + + if ( !initialized ) + { + BOOL result; + + initialized = TRUE; + + memset (&osver, 0, sizeof(OSVERSIONINFOA)); + osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); + result = GetVersionExA (&osver); + if (result) + { + if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) + is_wide = TRUE; + } + // If we can't even call to get the version, fall back to ANSI API + } + + return is_wide; } @@ -129,13 +129,13 @@ PrintWin32::is_os_wide() PrintWin32::PrintWin32 (void) { - /* Nothing here */ + /* Nothing here */ } PrintWin32::~PrintWin32 (void) { - DeleteDC (_hDC); + DeleteDC (_hDC); } @@ -146,237 +146,237 @@ static UINT_PTR CALLBACK print_hook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) { #if 0 - int cdown = 0; - while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) { - gtk_main_iteration_do (FALSE); - } - gtk_main_iteration_do (FALSE); + int cdown = 0; + while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) { + gtk_main_iteration_do (FALSE); + } + gtk_main_iteration_do (FALSE); #endif - return 0; + return 0; } unsigned int PrintWin32::setup (Inkscape::Extension::Print *mod) { - HRESULT res; - PRINTDLG pd = { - sizeof (PRINTDLG), - NULL, /* hwndOwner */ - NULL, /* hDevMode */ - NULL, /* hDevNames */ - NULL, /* hDC */ - PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE, /* Flags */ - 1, 1, 1, 1, /* nFromPage, nToPage, nMinPage, nMaxPage */ - 1, /* nCoies */ - NULL, /* hInstance */ - 0, /* lCustData */ - NULL, NULL, NULL, NULL, NULL, NULL - }; - UINT_PTR timer; - - SPWin32Modal = TRUE; - pd.Flags |= PD_ENABLEPRINTHOOK; - pd.lpfnPrintHook = print_hook; - timer = SetTimer (NULL, 0, 40, my_timer); - - res = PrintDlg (&pd); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!res) return FALSE; - - _hDC = pd.hDC; + HRESULT res; + PRINTDLG pd = { + sizeof (PRINTDLG), + NULL, /* hwndOwner */ + NULL, /* hDevMode */ + NULL, /* hDevNames */ + NULL, /* hDC */ + PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE, /* Flags */ + 1, 1, 1, 1, /* nFromPage, nToPage, nMinPage, nMaxPage */ + 1, /* nCoies */ + NULL, /* hInstance */ + 0, /* lCustData */ + NULL, NULL, NULL, NULL, NULL, NULL + }; + UINT_PTR timer; + + SPWin32Modal = TRUE; + pd.Flags |= PD_ENABLEPRINTHOOK; + pd.lpfnPrintHook = print_hook; + timer = SetTimer (NULL, 0, 40, my_timer); + + res = PrintDlg (&pd); + + KillTimer (NULL, timer); + SPWin32Modal = FALSE; + + if (!res) return FALSE; + + _hDC = pd.hDC; #if 0 - caps = GetDeviceCaps (_hDC, RASTERCAPS); - if (caps & RC_BANDING) { - printf ("needs banding\n"); - } - if (caps & RC_BITBLT) { - printf ("does bitblt\n"); - } - if (caps & RC_DIBTODEV) { - printf ("does dibtodev\n"); - } - if (caps & RC_STRETCHDIB) { - printf ("does stretchdib\n"); - } + caps = GetDeviceCaps (_hDC, RASTERCAPS); + if (caps & RC_BANDING) { + printf ("needs banding\n"); + } + if (caps & RC_BITBLT) { + printf ("does bitblt\n"); + } + if (caps & RC_DIBTODEV) { + printf ("does dibtodev\n"); + } + if (caps & RC_STRETCHDIB) { + printf ("does stretchdib\n"); + } #endif - if (pd.hDevMode) { - DEVMODE *devmodep; - devmodep = (DEVMODE *)pd.hDevMode; - if (devmodep->dmFields & DM_ORIENTATION) { - _landscape = (devmodep->dmOrientation == DMORIENT_LANDSCAPE); - } - } - - return TRUE; + if (pd.hDevMode) { + DEVMODE *devmodep; + devmodep = (DEVMODE *)pd.hDevMode; + if (devmodep->dmFields & DM_ORIENTATION) { + _landscape = (devmodep->dmOrientation == DMORIENT_LANDSCAPE); + } + } + + return TRUE; } unsigned int PrintWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) { - DOCINFO di = { - sizeof (DOCINFO), - NULL, /* lpszDocName */ - NULL, /* lpszOutput */ - NULL, /* lpszDatatype */ - 0 /* DI_APPBANDING */ /* fwType */ - }; - int res; + DOCINFO di = { + sizeof (DOCINFO), + NULL, /* lpszDocName */ + NULL, /* lpszOutput */ + NULL, /* lpszDatatype */ + 0 /* DI_APPBANDING */ /* fwType */ + }; + int res; - _PageWidth = sp_document_width (doc); - _PageHeight = sp_document_height (doc); + _PageWidth = sp_document_width (doc); + _PageHeight = sp_document_height (doc); - di.lpszDocName = SP_DOCUMENT_NAME (doc); + di.lpszDocName = SP_DOCUMENT_NAME (doc); - SPWin32Modal = TRUE; + SPWin32Modal = TRUE; - res = StartDoc (_hDC, &di); - res = StartPage (_hDC); + res = StartDoc (_hDC, &di); + res = StartPage (_hDC); - SPWin32Modal = FALSE; + SPWin32Modal = FALSE; - return 0; + return 0; } unsigned int PrintWin32::finish (Inkscape::Extension::Print *mod) { - int dpiX, dpiY; - int pPhysicalWidth, pPhysicalHeight; - int pPhysicalOffsetX, pPhysicalOffsetY; - int pPrintableWidth, pPrintableHeight; - float scalex, scaley; - int x0, y0, x1, y1; - int width, height; - NR::Matrix affine; - unsigned char *px; - int sheight, row; - BITMAPINFO bmInfo = { - { - sizeof (BITMAPINFOHEADER), // bV4Size - 64, // biWidth - 64, // biHeight - 1, // biPlanes - 32, // biBitCount - BI_RGB, // biCompression - 0, // biSizeImage - 2835, // biXPelsPerMeter - 2835, // biYPelsPerMeter - 0, // biClrUsed - 0 // biClrImportant - }, - { { 0, 0, 0, 0 } } // bmiColors - }; - //RECT wrect; - int res; - - SPWin32Modal = TRUE; - - // Number of pixels per logical inch - dpiX = (int) GetDeviceCaps (_hDC, LOGPIXELSX); - dpiY = (int) GetDeviceCaps (_hDC, LOGPIXELSY); - // Size in pixels of the printable area - pPhysicalWidth = GetDeviceCaps (_hDC, PHYSICALWIDTH); - pPhysicalHeight = GetDeviceCaps (_hDC, PHYSICALHEIGHT); - // Top left corner of prontable area - pPhysicalOffsetX = GetDeviceCaps (_hDC, PHYSICALOFFSETX); - pPhysicalOffsetY = GetDeviceCaps (_hDC, PHYSICALOFFSETY); - // Size in pixels of the printable area - pPrintableWidth = GetDeviceCaps (_hDC, HORZRES); - pPrintableHeight = GetDeviceCaps (_hDC, VERTRES); - - // Scaling from document to device - scalex = dpiX / 72.0; - scaley = dpiY / 72.0; - - // We simply map document 0,0 to physical page 0,0 - affine[0] = scalex / 1.25; - affine[1] = 0.0; - affine[2] = 0.0; - affine[3] = scaley / 1.25; - affine[4] = 0.0; - affine[5] = 0.0; - - nr_arena_item_set_transform (mod->root, &affine); - - // Calculate printable area in device coordinates - x0 = pPhysicalOffsetX; - y0 = pPhysicalOffsetY; - x1 = x0 + pPrintableWidth; - y1 = y0 + pPrintableHeight; - x1 = MIN (x1, (int) (_PageWidth * scalex)); - y1 = MIN (y1, (int) (_PageHeight * scaley)); - - width = x1 - x0; - height = y1 - y0; - - px = g_new (unsigned char, 4 * 64 * width); - sheight = 64; - - /* Printing goes here */ - for (row = 0; row < height; row += 64) { - NRPixBlock pb; - NRRectL bbox; - NRGC gc(NULL); - int num_rows; - int i; - - num_rows = sheight; - if ((row + num_rows) > height) num_rows = height - row; - - /* Set area of interest */ - bbox.x0 = x0; - bbox.y0 = y0 + row; - bbox.x1 = bbox.x0 + width; - bbox.y1 = bbox.y0 + num_rows; - /* Update to renderable state */ - gc.transform.set_identity(); - nr_arena_item_invoke_update (mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); - - nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, px, 4 * (bbox.x1 - bbox.x0), FALSE, FALSE); - - /* Blitter goes here */ - bmInfo.bmiHeader.biWidth = bbox.x1 - bbox.x0; - bmInfo.bmiHeader.biHeight = -(bbox.y1 - bbox.y0); - - memset (px, 0xff, 4 * num_rows * width); - /* Render */ - nr_arena_item_invoke_render (NULL, mod->root, &bbox, &pb, 0); - - /* Swap red and blue channels; we use RGBA, whereas - * the Win32 GDI uses BGRx. - */ - for ( i = 0 ; i < num_rows * width ; i++ ) { - unsigned char temp=px[i*4]; - px[i*4] = px[i*4+2]; - px[i*4+2] = temp; - } - - SetStretchBltMode(_hDC, COLORONCOLOR); - res = StretchDIBits (_hDC, - bbox.x0 - x0, bbox.y0 - y0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, - 0, 0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, - px, - &bmInfo, + int dpiX, dpiY; + int pPhysicalWidth, pPhysicalHeight; + int pPhysicalOffsetX, pPhysicalOffsetY; + int pPrintableWidth, pPrintableHeight; + float scalex, scaley; + int x0, y0, x1, y1; + int width, height; + NR::Matrix affine; + unsigned char *px; + int sheight, row; + BITMAPINFO bmInfo = { + { + sizeof (BITMAPINFOHEADER), // bV4Size + 64, // biWidth + 64, // biHeight + 1, // biPlanes + 32, // biBitCount + BI_RGB, // biCompression + 0, // biSizeImage + 2835, // biXPelsPerMeter + 2835, // biYPelsPerMeter + 0, // biClrUsed + 0 // biClrImportant + }, + { { 0, 0, 0, 0 } } // bmiColors + }; + //RECT wrect; + int res; + + SPWin32Modal = TRUE; + + // Number of pixels per logical inch + dpiX = (int) GetDeviceCaps (_hDC, LOGPIXELSX); + dpiY = (int) GetDeviceCaps (_hDC, LOGPIXELSY); + // Size in pixels of the printable area + pPhysicalWidth = GetDeviceCaps (_hDC, PHYSICALWIDTH); + pPhysicalHeight = GetDeviceCaps (_hDC, PHYSICALHEIGHT); + // Top left corner of prontable area + pPhysicalOffsetX = GetDeviceCaps (_hDC, PHYSICALOFFSETX); + pPhysicalOffsetY = GetDeviceCaps (_hDC, PHYSICALOFFSETY); + // Size in pixels of the printable area + pPrintableWidth = GetDeviceCaps (_hDC, HORZRES); + pPrintableHeight = GetDeviceCaps (_hDC, VERTRES); + + // Scaling from document to device + scalex = dpiX / 72.0; + scaley = dpiY / 72.0; + + // We simply map document 0,0 to physical page 0,0 + affine[0] = scalex / 1.25; + affine[1] = 0.0; + affine[2] = 0.0; + affine[3] = scaley / 1.25; + affine[4] = 0.0; + affine[5] = 0.0; + + nr_arena_item_set_transform (mod->root, &affine); + + // Calculate printable area in device coordinates + x0 = pPhysicalOffsetX; + y0 = pPhysicalOffsetY; + x1 = x0 + pPrintableWidth; + y1 = y0 + pPrintableHeight; + x1 = MIN (x1, (int) (_PageWidth * scalex)); + y1 = MIN (y1, (int) (_PageHeight * scaley)); + + width = x1 - x0; + height = y1 - y0; + + px = g_new (unsigned char, 4 * 64 * width); + sheight = 64; + + /* Printing goes here */ + for (row = 0; row < height; row += 64) { + NRPixBlock pb; + NRRectL bbox; + NRGC gc(NULL); + int num_rows; + int i; + + num_rows = sheight; + if ((row + num_rows) > height) num_rows = height - row; + + /* Set area of interest */ + bbox.x0 = x0; + bbox.y0 = y0 + row; + bbox.x1 = bbox.x0 + width; + bbox.y1 = bbox.y0 + num_rows; + /* Update to renderable state */ + gc.transform.set_identity(); + nr_arena_item_invoke_update (mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); + + nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, px, 4 * (bbox.x1 - bbox.x0), FALSE, FALSE); + + /* Blitter goes here */ + bmInfo.bmiHeader.biWidth = bbox.x1 - bbox.x0; + bmInfo.bmiHeader.biHeight = -(bbox.y1 - bbox.y0); + + memset (px, 0xff, 4 * num_rows * width); + /* Render */ + nr_arena_item_invoke_render (NULL, mod->root, &bbox, &pb, 0); + + /* Swap red and blue channels; we use RGBA, whereas + * the Win32 GDI uses BGRx. + */ + for ( i = 0 ; i < num_rows * width ; i++ ) { + unsigned char temp=px[i*4]; + px[i*4] = px[i*4+2]; + px[i*4+2] = temp; + } + + SetStretchBltMode(_hDC, COLORONCOLOR); + res = StretchDIBits (_hDC, + bbox.x0 - x0, bbox.y0 - y0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, + 0, 0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, + px, + &bmInfo, DIB_RGB_COLORS, SRCCOPY); - /* Blitter ends here */ + /* Blitter ends here */ - nr_pixblock_release (&pb); - } + nr_pixblock_release (&pb); + } - g_free (px); + g_free (px); - res = EndPage (_hDC); - res = EndDoc (_hDC); + res = EndPage (_hDC); + res = EndDoc (_hDC); - SPWin32Modal = FALSE; + SPWin32Modal = FALSE; - return 0; + return 0; } /* File dialogs */ @@ -384,98 +384,98 @@ PrintWin32::finish (Inkscape::Extension::Print *mod) char * PrintWin32::get_open_filename (unsigned char *dir, unsigned char *filter, unsigned char *title) { - char fnbuf[4096] = {0}; - OPENFILENAME ofn = { - sizeof (OPENFILENAME), - NULL, /* hwndOwner */ - NULL, /* hInstance */ - (const CHAR *)filter, /* lpstrFilter */ - NULL, /* lpstrCustomFilter */ - 0, /* nMaxCustFilter */ - 1, /* nFilterIndex */ - fnbuf, /* lpstrFile */ - sizeof (fnbuf), /* nMaxFile */ - NULL, /* lpstrFileTitle */ - 0, /* nMaxFileTitle */ - (const CHAR *)dir, /* lpstrInitialDir */ - (const CHAR *)title, /* lpstrTitle */ - OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, /* Flags */ - 0, /* nFileOffset */ - 0, /* nFileExtension */ - NULL, /* lpstrDefExt */ - 0, /* lCustData */ - NULL, /* lpfnHook */ - NULL /* lpTemplateName */ - }; - int retval; - UINT_PTR timer; - - SPWin32Modal = TRUE; - timer = SetTimer (NULL, 0, 40, my_timer); - - retval = GetOpenFileName (&ofn); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!retval) { - int errcode; - errcode = CommDlgExtendedError(); - return NULL; + char fnbuf[4096] = {0}; + OPENFILENAME ofn = { + sizeof (OPENFILENAME), + NULL, /* hwndOwner */ + NULL, /* hInstance */ + (const CHAR *)filter, /* lpstrFilter */ + NULL, /* lpstrCustomFilter */ + 0, /* nMaxCustFilter */ + 1, /* nFilterIndex */ + fnbuf, /* lpstrFile */ + sizeof (fnbuf), /* nMaxFile */ + NULL, /* lpstrFileTitle */ + 0, /* nMaxFileTitle */ + (const CHAR *)dir, /* lpstrInitialDir */ + (const CHAR *)title, /* lpstrTitle */ + OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, /* Flags */ + 0, /* nFileOffset */ + 0, /* nFileExtension */ + NULL, /* lpstrDefExt */ + 0, /* lCustData */ + NULL, /* lpfnHook */ + NULL /* lpTemplateName */ + }; + int retval; + UINT_PTR timer; + + SPWin32Modal = TRUE; + timer = SetTimer (NULL, 0, 40, my_timer); + + retval = GetOpenFileName (&ofn); + + KillTimer (NULL, timer); + SPWin32Modal = FALSE; + + if (!retval) { + int errcode; + errcode = CommDlgExtendedError(); + return NULL; } - return g_strdup (fnbuf); + return g_strdup (fnbuf); } char * PrintWin32::get_write_filename (unsigned char *dir, unsigned char *filter, unsigned char *title) { - return NULL; + return NULL; } char * PrintWin32::get_save_filename (unsigned char *dir, unsigned int *spns) { - char fnbuf[4096] = {0}; - OPENFILENAME ofn = { - sizeof (OPENFILENAME), - NULL, /* hwndOwner */ - NULL, /* hInstance */ - "Inkscape SVG (*.svg)\0*\0Plain SVG (*.svg)\0*\0", /* lpstrFilter */ - NULL, /* lpstrCustomFilter */ - 0, /* nMaxCustFilter */ - 1, /* nFilterIndex */ - fnbuf, /* lpstrFile */ - sizeof (fnbuf), /* nMaxFile */ - NULL, /* lpstrFileTitle */ - 0, /* nMaxFileTitle */ - (const CHAR *)dir, /* lpstrInitialDir */ - "Save document to file", /* lpstrTitle */ - OFN_HIDEREADONLY, /* Flags */ - 0, /* nFileOffset */ - 0, /* nFileExtension */ - NULL, /* lpstrDefExt */ - 0, /* lCustData */ - NULL, /* lpfnHook */ - NULL /* lpTemplateName */ - }; - int retval; - UINT_PTR timer; - - SPWin32Modal = TRUE; - timer = SetTimer (NULL, 0, 40, my_timer); - - retval = GetSaveFileName (&ofn); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!retval) { - int errcode; - errcode = CommDlgExtendedError(); - return NULL; + char fnbuf[4096] = {0}; + OPENFILENAME ofn = { + sizeof (OPENFILENAME), + NULL, /* hwndOwner */ + NULL, /* hInstance */ + "Inkscape SVG (*.svg)\0*\0Plain SVG (*.svg)\0*\0", /* lpstrFilter */ + NULL, /* lpstrCustomFilter */ + 0, /* nMaxCustFilter */ + 1, /* nFilterIndex */ + fnbuf, /* lpstrFile */ + sizeof (fnbuf), /* nMaxFile */ + NULL, /* lpstrFileTitle */ + 0, /* nMaxFileTitle */ + (const CHAR *)dir, /* lpstrInitialDir */ + "Save document to file", /* lpstrTitle */ + OFN_HIDEREADONLY, /* Flags */ + 0, /* nFileOffset */ + 0, /* nFileExtension */ + NULL, /* lpstrDefExt */ + 0, /* lCustData */ + NULL, /* lpfnHook */ + NULL /* lpTemplateName */ + }; + int retval; + UINT_PTR timer; + + SPWin32Modal = TRUE; + timer = SetTimer (NULL, 0, 40, my_timer); + + retval = GetSaveFileName (&ofn); + + KillTimer (NULL, timer); + SPWin32Modal = FALSE; + + if (!retval) { + int errcode; + errcode = CommDlgExtendedError(); + return NULL; } - *spns = (ofn.nFilterIndex != 2); - return g_strdup (fnbuf); + *spns = (ofn.nFilterIndex != 2); + return g_strdup (fnbuf); } #include "clear-n_.h" @@ -483,18 +483,18 @@ PrintWin32::get_save_filename (unsigned char *dir, unsigned int *spns) void PrintWin32::init (void) { - Inkscape::Extension::Extension * ext; + Inkscape::Extension::Extension * ext; - /* SVG in */ + /* SVG in */ ext = Inkscape::Extension::build_from_mem( - "\n" - "" N_("Windows 32-bit Print") "\n" - "" SP_MODULE_KEY_PRINT_WIN32 "\n" - "true\n" - "\n" - "", new PrintWin32()); - - return; + "\n" + "" N_("Windows 32-bit Print") "\n" + "" SP_MODULE_KEY_PRINT_WIN32 "\n" + "true\n" + "\n" + "", new PrintWin32()); + + return; } } /* namespace Internal */ diff --git a/src/extension/internal/win32.h b/src/extension/internal/win32.h index 8fd16edf2..f32e354ee 100644 --- a/src/extension/internal/win32.h +++ b/src/extension/internal/win32.h @@ -71,15 +71,15 @@ public: /* Rendering methods */ /* - virtual unsigned int bind (Inkscape::Extension::Print * module, const NR::Matrix *transform, float opacity); + virtual unsigned int bind (Inkscape::Extension::Print * module, const Geom::Matrix *transform, float opacity); virtual unsigned int release (Inkscape::Extension::Print * module); virtual unsigned int comment (Inkscape::Extension::Print * module, const char * comment); - virtual unsigned int fill (Inkscape::Extension::Print * module, const const_NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, + virtual unsigned int fill (Inkscape::Extension::Print * module, const const_NRBPath *bpath, const Geom::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); - virtual unsigned int stroke (Inkscape::Extension::Print * module, const const_NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, + virtual unsigned int stroke (Inkscape::Extension::Print * module, const const_NRBPath *bpath, const Geom::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int image (Inkscape::Extension::Print * module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - const NR::Matrix *transform, const SPStyle *style); + const Geom::Matrix *transform, const SPStyle *style); */ }; diff --git a/src/extension/print.cpp b/src/extension/print.cpp index 035865825..2d4177d60 100644 --- a/src/extension/print.cpp +++ b/src/extension/print.cpp @@ -61,7 +61,7 @@ Print::finish (void) } unsigned int -Print::bind (const NR::Matrix *transform, float opacity) +Print::bind (const Geom::Matrix *transform, float opacity) { return imp->bind (this, transform, opacity); } @@ -79,14 +79,14 @@ Print::comment (const char * comment) } unsigned int -Print::fill (Geom::PathVector const &pathv, const NR::Matrix *ctm, const SPStyle *style, +Print::fill (Geom::PathVector const &pathv, const Geom::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { return imp->fill (this, pathv, ctm, style, pbox, dbox, bbox); } unsigned int -Print::stroke (Geom::PathVector const &pathv, const NR::Matrix *transform, const SPStyle *style, +Print::stroke (Geom::PathVector const &pathv, const Geom::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { return imp->stroke (this, pathv, transform, style, pbox, dbox, bbox); @@ -94,13 +94,13 @@ Print::stroke (Geom::PathVector const &pathv, const NR::Matrix *transform, const unsigned int Print::image (unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - const NR::Matrix *transform, const SPStyle *style) + const Geom::Matrix *transform, const SPStyle *style) { return imp->image (this, px, w, h, rs, transform, style); } unsigned int -Print::text (const char* text, NR::Point p, const SPStyle* style) +Print::text (const char* text, Geom::Point p, const SPStyle* style) { return imp->text (this, text, p, style); } diff --git a/src/extension/print.h b/src/extension/print.h index c5f49dd9d..de9c8c598 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -41,18 +41,18 @@ public: unsigned int finish (void); /* Rendering methods */ - unsigned int bind (NR::Matrix const *transform, + unsigned int bind (Geom::Matrix const *transform, float opacity); unsigned int release (void); unsigned int comment (const char * comment); unsigned int fill (Geom::PathVector const &pathv, - NR::Matrix const *ctm, + Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); unsigned int stroke (Geom::PathVector const &pathv, - NR::Matrix const *transform, + Geom::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, @@ -61,10 +61,10 @@ public: unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *transform, + Geom::Matrix const *transform, SPStyle const *style); unsigned int text (char const *text, - NR::Point p, + Geom::Point p, SPStyle const *style); bool textToPath (void); bool fontEmbedded (void); diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index b2de090a0..aa3875048 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -141,6 +141,7 @@ void Layout::print(SPPrintContext *ctx, { if (_input_stream.empty()) return; + Geom::Matrix ctm_2geom(ctm); Direction block_progression = _blockProgression(); bool text_to_path = ctx->module->textToPath(); for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; ) { @@ -160,9 +161,9 @@ void Layout::print(SPPrintContext *ctx, _getGlyphTransformMatrix(glyph_index, &glyph_matrix); Geom::PathVector temp_pv = (*pv) * glyph_matrix; if (!text_source->style->fill.isNone()) - sp_print_fill(ctx, temp_pv, &ctm, text_source->style, pbox, dbox, bbox); + sp_print_fill(ctx, temp_pv, &ctm_2geom, text_source->style, pbox, dbox, bbox); if (!text_source->style->stroke.isNone()) - sp_print_stroke(ctx, temp_pv, &ctm, text_source->style, pbox, dbox, bbox); + sp_print_stroke(ctx, temp_pv, &ctm_2geom, text_source->style, pbox, dbox, bbox); } glyph_index++; } else { @@ -297,14 +298,14 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const if (_path_fitted) { ctx->pushState(); - ctx->transform(&glyph_matrix); + ctx->transform(&to_2geom(glyph_matrix)); } else if (opacity != 1.0) { ctx->pushState(); ctx->setStateForStyle(style); ctx->pushLayer(); } if (glyph_index - first_index > 0) - ctx->renderGlyphtext(span.font->pFont, &font_matrix, glyphtext, style); + ctx->renderGlyphtext(span.font->pFont, &to_2geom(font_matrix), glyphtext, style); if (_path_fitted) ctx->popState(); else if (opacity != 1.0) { diff --git a/src/print.cpp b/src/print.cpp index 6d4572031..7b032fe4e 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -27,14 +27,14 @@ /* Identity typedef */ -unsigned int sp_print_bind(SPPrintContext *ctx, NR::Matrix const &transform, float opacity) +unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Matrix const &transform, float opacity) { - NR::Matrix const ntransform(transform); + Geom::Matrix const ntransform(transform); return sp_print_bind(ctx, &ntransform, opacity); } unsigned int -sp_print_bind(SPPrintContext *ctx, NR::Matrix const *transform, float opacity) +sp_print_bind(SPPrintContext *ctx, Geom::Matrix const *transform, float opacity) { return ctx->module->bind(transform, opacity); } @@ -52,14 +52,14 @@ sp_print_comment(SPPrintContext *ctx, char const *comment) } unsigned int -sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *style, +sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { return ctx->module->fill(pathv, ctm, style, pbox, dbox, bbox); } unsigned int -sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *style, +sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { return ctx->module->stroke(pathv, ctm, style, pbox, dbox, bbox); @@ -68,12 +68,12 @@ sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, NR::Matrix c unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *transform, SPStyle const *style) + Geom::Matrix const *transform, SPStyle const *style) { return ctx->module->image(px, w, h, rs, transform, style); } -unsigned int sp_print_text(SPPrintContext *ctx, char const *text, NR::Point p, +unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, SPStyle const *style) { return ctx->module->text(text, p, style); diff --git a/src/print.h b/src/print.h index ed56c9663..577a169cf 100644 --- a/src/print.h +++ b/src/print.h @@ -12,7 +12,7 @@ */ #include -#include +//#include #include <2geom/forward.h> #include "forward.h" #include "extension/extension-forward.h" @@ -21,20 +21,20 @@ struct SPPrintContext { Inkscape::Extension::Print *module; }; -unsigned int sp_print_bind(SPPrintContext *ctx, NR::Matrix const &transform, float opacity); -unsigned int sp_print_bind(SPPrintContext *ctx, NR::Matrix const *transform, float opacity); +unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Matrix const &transform, float opacity); +unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Matrix const *transform, float opacity); unsigned int sp_print_release(SPPrintContext *ctx); unsigned int sp_print_comment(SPPrintContext *ctx, char const *comment); -unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, NR::Matrix const *ctm, SPStyle const *style, +unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); -unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, NR::Matrix const *transform, SPStyle const *style, +unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NR::Matrix const *transform, SPStyle const *style); + Geom::Matrix const *transform, SPStyle const *style); -unsigned int sp_print_text(SPPrintContext *ctx, char const *text, NR::Point p, +unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, SPStyle const *style); void sp_print_get_param(SPPrintContext *ctx, gchar *name, bool *value); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 5a02517e2..f49812ac7 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1068,18 +1068,18 @@ sp_image_print (SPItem *item, SPPrintContext *ctx) rs = gdk_pixbuf_get_rowstride (image->pixbuf); pixskip = gdk_pixbuf_get_n_channels (image->pixbuf) * gdk_pixbuf_get_bits_per_sample (image->pixbuf) / 8; - NR::Matrix t; + Geom::Matrix t; if (image->aspect_align == SP_ASPECT_NONE) { /* fixme: (Lauris) */ - NR::translate tp = NR::translate(image->x.computed, image->y.computed); - NR::scale s = NR::scale(image->width.computed, -image->height.computed); - NR::translate ti = NR::translate(0.0, -1.0); + Geom::Translate tp (image->x.computed, image->y.computed); + Geom::Scale s (image->width.computed, -image->height.computed); + Geom::Translate ti (0.0, -1.0); t = s * tp; t = ti * t; } else { // preserveAspectRatio - NR::translate tp = NR::translate(image->viewx, image->viewy); - NR::scale s = NR::scale(image->viewwidth, -image->viewheight); - NR::translate ti = NR::translate(0.0, -1.0); + Geom::Translate tp (image->viewx, image->viewy); + Geom::Scale s (image->viewwidth, -image->viewheight); + Geom::Translate ti (0.0, -1.0); t = s * tp; t = ti * t; } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 7c1cd20ea..92c1e5128 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -631,14 +631,14 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) g_free(comment); } - /* fixme: Think (Lauris) */ - sp_item_invoke_bbox(item, &pbox, NR::identity(), TRUE); - dbox.x0 = 0.0; - dbox.y0 = 0.0; - dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); - dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); - sp_item_bbox_desktop (item, &bbox); - NR::Matrix const i2d(sp_item_i2d_affine(item)); + /* fixme: Think (Lauris) */ + sp_item_invoke_bbox(item, &pbox, NR::identity(), TRUE); + dbox.x0 = 0.0; + dbox.y0 = 0.0; + dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); + dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); + sp_item_bbox_desktop (item, &bbox); + Geom::Matrix const i2d(sp_item_i2d_affine(item)); SPStyle* style = SP_OBJECT_STYLE (item); diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 7420f660e..064c43442 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -48,426 +48,426 @@ static SPGroupClass *parent_class; GType sp_symbol_get_type (void) { - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPSymbolClass), - NULL, NULL, - (GClassInitFunc) sp_symbol_class_init, - NULL, NULL, - sizeof (SPSymbol), - 16, - (GInstanceInitFunc) sp_symbol_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_GROUP, "SPSymbol", &info, (GTypeFlags)0); - } - return type; + static GType type = 0; + if (!type) { + GTypeInfo info = { + sizeof (SPSymbolClass), + NULL, NULL, + (GClassInitFunc) sp_symbol_class_init, + NULL, NULL, + sizeof (SPSymbol), + 16, + (GInstanceInitFunc) sp_symbol_init, + NULL, /* value_table */ + }; + type = g_type_register_static (SP_TYPE_GROUP, "SPSymbol", &info, (GTypeFlags)0); + } + return type; } static void sp_symbol_class_init (SPSymbolClass *klass) { - GObjectClass *object_class; - SPObjectClass *sp_object_class; - SPItemClass *sp_item_class; - - object_class = G_OBJECT_CLASS (klass); - sp_object_class = (SPObjectClass *) klass; - sp_item_class = (SPItemClass *) klass; - - parent_class = (SPGroupClass *)g_type_class_ref (SP_TYPE_GROUP); - - sp_object_class->build = sp_symbol_build; - sp_object_class->release = sp_symbol_release; - sp_object_class->set = sp_symbol_set; - sp_object_class->child_added = sp_symbol_child_added; - sp_object_class->update = sp_symbol_update; - sp_object_class->modified = sp_symbol_modified; - sp_object_class->write = sp_symbol_write; - - sp_item_class->show = sp_symbol_show; - sp_item_class->hide = sp_symbol_hide; - sp_item_class->bbox = sp_symbol_bbox; - sp_item_class->print = sp_symbol_print; + GObjectClass *object_class; + SPObjectClass *sp_object_class; + SPItemClass *sp_item_class; + + object_class = G_OBJECT_CLASS (klass); + sp_object_class = (SPObjectClass *) klass; + sp_item_class = (SPItemClass *) klass; + + parent_class = (SPGroupClass *)g_type_class_ref (SP_TYPE_GROUP); + + sp_object_class->build = sp_symbol_build; + sp_object_class->release = sp_symbol_release; + sp_object_class->set = sp_symbol_set; + sp_object_class->child_added = sp_symbol_child_added; + sp_object_class->update = sp_symbol_update; + sp_object_class->modified = sp_symbol_modified; + sp_object_class->write = sp_symbol_write; + + sp_item_class->show = sp_symbol_show; + sp_item_class->hide = sp_symbol_hide; + sp_item_class->bbox = sp_symbol_bbox; + sp_item_class->print = sp_symbol_print; } static void sp_symbol_init (SPSymbol *symbol) { - symbol->viewBox_set = FALSE; + symbol->viewBox_set = FALSE; - symbol->c2p.set_identity(); + symbol->c2p = Geom::identity(); } static void sp_symbol_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - SPGroup *group; - SPSymbol *symbol; + SPGroup *group; + SPSymbol *symbol; - group = (SPGroup *) object; - symbol = (SPSymbol *) object; + group = (SPGroup *) object; + symbol = (SPSymbol *) object; - sp_object_read_attr (object, "viewBox"); - sp_object_read_attr (object, "preserveAspectRatio"); + sp_object_read_attr (object, "viewBox"); + sp_object_read_attr (object, "preserveAspectRatio"); - if (((SPObjectClass *) parent_class)->build) - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) parent_class)->build) + ((SPObjectClass *) parent_class)->build (object, document, repr); } static void sp_symbol_release (SPObject *object) { - SPSymbol * symbol; + SPSymbol * symbol; - symbol = (SPSymbol *) object; + symbol = (SPSymbol *) object; - if (((SPObjectClass *) parent_class)->release) - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) parent_class)->release) + ((SPObjectClass *) parent_class)->release (object); } static void sp_symbol_set (SPObject *object, unsigned int key, const gchar *value) { - SPItem *item; - SPSymbol *symbol; - - item = SP_ITEM (object); - symbol = SP_SYMBOL (object); - - switch (key) { - case SP_ATTR_VIEWBOX: - if (value) { - double x, y, width, height; - char *eptr; - /* fixme: We have to take original item affine into account */ - /* fixme: Think (Lauris) */ - eptr = (gchar *) value; - x = g_ascii_strtod (eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; - y = g_ascii_strtod (eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; - width = g_ascii_strtod (eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; - height = g_ascii_strtod (eptr, &eptr); - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; - if ((width > 0) && (height > 0)) { - /* Set viewbox */ - symbol->viewBox.x0 = x; - symbol->viewBox.y0 = y; - symbol->viewBox.x1 = x + width; - symbol->viewBox.y1 = y + height; - symbol->viewBox_set = TRUE; - } else { - symbol->viewBox_set = FALSE; - } - } else { - symbol->viewBox_set = FALSE; - } - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; - case SP_ATTR_PRESERVEASPECTRATIO: - /* Do setup before, so we can use break to escape */ - symbol->aspect_set = FALSE; - symbol->aspect_align = SP_ASPECT_NONE; - symbol->aspect_clip = SP_ASPECT_MEET; - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - if (value) { - int len; - gchar c[256]; - const gchar *p, *e; - unsigned int align, clip; - p = value; - while (*p && *p == 32) p += 1; - if (!*p) break; - e = p; - while (*e && *e != 32) e += 1; - len = e - p; - if (len > 8) break; - memcpy (c, value, len); - c[len] = 0; - /* Now the actual part */ - if (!strcmp (c, "none")) { - align = SP_ASPECT_NONE; - } else if (!strcmp (c, "xMinYMin")) { - align = SP_ASPECT_XMIN_YMIN; - } else if (!strcmp (c, "xMidYMin")) { - align = SP_ASPECT_XMID_YMIN; - } else if (!strcmp (c, "xMaxYMin")) { - align = SP_ASPECT_XMAX_YMIN; - } else if (!strcmp (c, "xMinYMid")) { - align = SP_ASPECT_XMIN_YMID; - } else if (!strcmp (c, "xMidYMid")) { - align = SP_ASPECT_XMID_YMID; - } else if (!strcmp (c, "xMaxYMin")) { - align = SP_ASPECT_XMAX_YMID; - } else if (!strcmp (c, "xMinYMax")) { - align = SP_ASPECT_XMIN_YMAX; - } else if (!strcmp (c, "xMidYMax")) { - align = SP_ASPECT_XMID_YMAX; - } else if (!strcmp (c, "xMaxYMax")) { - align = SP_ASPECT_XMAX_YMAX; - } else { - break; - } - clip = SP_ASPECT_MEET; - while (*e && *e == 32) e += 1; - if (e) { - if (!strcmp (e, "meet")) { - clip = SP_ASPECT_MEET; - } else if (!strcmp (e, "slice")) { - clip = SP_ASPECT_SLICE; - } else { - break; - } - } - symbol->aspect_set = TRUE; - symbol->aspect_align = align; - symbol->aspect_clip = clip; - } - break; - default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); - break; - } + SPItem *item; + SPSymbol *symbol; + + item = SP_ITEM (object); + symbol = SP_SYMBOL (object); + + switch (key) { + case SP_ATTR_VIEWBOX: + if (value) { + double x, y, width, height; + char *eptr; + /* fixme: We have to take original item affine into account */ + /* fixme: Think (Lauris) */ + eptr = (gchar *) value; + x = g_ascii_strtod (eptr, &eptr); + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; + y = g_ascii_strtod (eptr, &eptr); + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; + width = g_ascii_strtod (eptr, &eptr); + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; + height = g_ascii_strtod (eptr, &eptr); + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; + if ((width > 0) && (height > 0)) { + /* Set viewbox */ + symbol->viewBox.x0 = x; + symbol->viewBox.y0 = y; + symbol->viewBox.x1 = x + width; + symbol->viewBox.y1 = y + height; + symbol->viewBox_set = TRUE; + } else { + symbol->viewBox_set = FALSE; + } + } else { + symbol->viewBox_set = FALSE; + } + object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; + case SP_ATTR_PRESERVEASPECTRATIO: + /* Do setup before, so we can use break to escape */ + symbol->aspect_set = FALSE; + symbol->aspect_align = SP_ASPECT_NONE; + symbol->aspect_clip = SP_ASPECT_MEET; + object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + if (value) { + int len; + gchar c[256]; + const gchar *p, *e; + unsigned int align, clip; + p = value; + while (*p && *p == 32) p += 1; + if (!*p) break; + e = p; + while (*e && *e != 32) e += 1; + len = e - p; + if (len > 8) break; + memcpy (c, value, len); + c[len] = 0; + /* Now the actual part */ + if (!strcmp (c, "none")) { + align = SP_ASPECT_NONE; + } else if (!strcmp (c, "xMinYMin")) { + align = SP_ASPECT_XMIN_YMIN; + } else if (!strcmp (c, "xMidYMin")) { + align = SP_ASPECT_XMID_YMIN; + } else if (!strcmp (c, "xMaxYMin")) { + align = SP_ASPECT_XMAX_YMIN; + } else if (!strcmp (c, "xMinYMid")) { + align = SP_ASPECT_XMIN_YMID; + } else if (!strcmp (c, "xMidYMid")) { + align = SP_ASPECT_XMID_YMID; + } else if (!strcmp (c, "xMaxYMin")) { + align = SP_ASPECT_XMAX_YMID; + } else if (!strcmp (c, "xMinYMax")) { + align = SP_ASPECT_XMIN_YMAX; + } else if (!strcmp (c, "xMidYMax")) { + align = SP_ASPECT_XMID_YMAX; + } else if (!strcmp (c, "xMaxYMax")) { + align = SP_ASPECT_XMAX_YMAX; + } else { + break; + } + clip = SP_ASPECT_MEET; + while (*e && *e == 32) e += 1; + if (e) { + if (!strcmp (e, "meet")) { + clip = SP_ASPECT_MEET; + } else if (!strcmp (e, "slice")) { + clip = SP_ASPECT_SLICE; + } else { + break; + } + } + symbol->aspect_set = TRUE; + symbol->aspect_align = align; + symbol->aspect_clip = clip; + } + break; + default: + if (((SPObjectClass *) parent_class)->set) + ((SPObjectClass *) parent_class)->set (object, key, value); + break; + } } static void sp_symbol_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPSymbol *symbol; - SPGroup *group; + SPSymbol *symbol; + SPGroup *group; - symbol = (SPSymbol *) object; - group = (SPGroup *) object; + symbol = (SPSymbol *) object; + group = (SPGroup *) object; - if (((SPObjectClass *) (parent_class))->child_added) - ((SPObjectClass *) (parent_class))->child_added (object, child, ref); + if (((SPObjectClass *) (parent_class))->child_added) + ((SPObjectClass *) (parent_class))->child_added (object, child, ref); } static void sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags) { - SPItem *item; - SPSymbol *symbol; - SPItemCtx *ictx, rctx; - SPItemView *v; + SPItem *item; + SPSymbol *symbol; + SPItemCtx *ictx, rctx; + SPItemView *v; - item = SP_ITEM (object); - symbol = SP_SYMBOL (object); - ictx = (SPItemCtx *) ctx; + item = SP_ITEM (object); + symbol = SP_SYMBOL (object); + ictx = (SPItemCtx *) ctx; - if (SP_OBJECT_IS_CLONED (object)) { - /* Cloned is actually renderable */ + if (SP_OBJECT_IS_CLONED (object)) { + /* Cloned is actually renderable */ - /* fixme: We have to set up clip here too */ + /* fixme: We have to set up clip here too */ - /* Create copy of item context */ - rctx = *ictx; + /* Create copy of item context */ + rctx = *ictx; - /* Calculate child to parent transformation */ - /* Apply parent translation (set up as vewport) */ + /* Calculate child to parent transformation */ + /* Apply parent translation (set up as vewport) */ symbol->c2p = NR::Matrix(NR::translate(rctx.vp.x0, rctx.vp.y0)); - if (symbol->viewBox_set) { - double x, y, width, height; - NR::Matrix q; - /* Determine actual viewbox in viewport coordinates */ - if (symbol->aspect_align == SP_ASPECT_NONE) { - x = 0.0; - y = 0.0; - width = rctx.vp.x1 - rctx.vp.x0; - height = rctx.vp.y1 - rctx.vp.y0; - } else { - double scalex, scaley, scale; - /* Things are getting interesting */ - scalex = (rctx.vp.x1 - rctx.vp.x0) / (symbol->viewBox.x1 - symbol->viewBox.x0); - scaley = (rctx.vp.y1 - rctx.vp.y0) / (symbol->viewBox.y1 - symbol->viewBox.y0); - scale = (symbol->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); - width = (symbol->viewBox.x1 - symbol->viewBox.x0) * scale; - height = (symbol->viewBox.y1 - symbol->viewBox.y0) * scale; - /* Now place viewbox to requested position */ - switch (symbol->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; - case SP_ASPECT_XMID_YMIN: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.0; - break; - case SP_ASPECT_XMAX_YMIN: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.0; - break; - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); - break; - case SP_ASPECT_XMID_YMID: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); - break; - case SP_ASPECT_XMAX_YMID: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); - break; - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); - break; - case SP_ASPECT_XMID_YMAX: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); - break; - case SP_ASPECT_XMAX_YMAX: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); - break; - default: - x = 0.0; - y = 0.0; - break; - } - } - /* Compose additional transformation from scale and position */ - q[0] = width / (symbol->viewBox.x1 - symbol->viewBox.x0); - q[1] = 0.0; - q[2] = 0.0; - q[3] = height / (symbol->viewBox.y1 - symbol->viewBox.y0); - q[4] = -symbol->viewBox.x0 * q[0] + x; - q[5] = -symbol->viewBox.y0 * q[3] + y; - /* Append viewbox transformation */ - symbol->c2p = q * symbol->c2p; - } - - rctx.i2doc = symbol->c2p * rctx.i2doc; - - /* If viewBox is set initialize child viewport */ - /* Otherwise has set it up already */ - if (symbol->viewBox_set) { - rctx.vp.x0 = symbol->viewBox.x0; - rctx.vp.y0 = symbol->viewBox.y0; - rctx.vp.x1 = symbol->viewBox.x1; - rctx.vp.y1 = symbol->viewBox.y1; - rctx.i2vp = NR::identity(); - } - - /* And invoke parent method */ - if (((SPObjectClass *) (parent_class))->update) - ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); - - /* As last step set additional transform of arena group */ - for (v = item->display; v != NULL; v = v->next) { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), &symbol->c2p); - } - } else { - /* No-op */ - if (((SPObjectClass *) (parent_class))->update) - ((SPObjectClass *) (parent_class))->update (object, ctx, flags); - } + if (symbol->viewBox_set) { + double x, y, width, height; + /* Determine actual viewbox in viewport coordinates */ + if (symbol->aspect_align == SP_ASPECT_NONE) { + x = 0.0; + y = 0.0; + width = rctx.vp.x1 - rctx.vp.x0; + height = rctx.vp.y1 - rctx.vp.y0; + } else { + double scalex, scaley, scale; + /* Things are getting interesting */ + scalex = (rctx.vp.x1 - rctx.vp.x0) / (symbol->viewBox.x1 - symbol->viewBox.x0); + scaley = (rctx.vp.y1 - rctx.vp.y0) / (symbol->viewBox.y1 - symbol->viewBox.y0); + scale = (symbol->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); + width = (symbol->viewBox.x1 - symbol->viewBox.x0) * scale; + height = (symbol->viewBox.y1 - symbol->viewBox.y0) * scale; + /* Now place viewbox to requested position */ + switch (symbol->aspect_align) { + case SP_ASPECT_XMIN_YMIN: + x = 0.0; + y = 0.0; + break; + case SP_ASPECT_XMID_YMIN: + x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); + y = 0.0; + break; + case SP_ASPECT_XMAX_YMIN: + x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); + y = 0.0; + break; + case SP_ASPECT_XMIN_YMID: + x = 0.0; + y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + break; + case SP_ASPECT_XMID_YMID: + x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); + y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + break; + case SP_ASPECT_XMAX_YMID: + x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); + y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + break; + case SP_ASPECT_XMIN_YMAX: + x = 0.0; + y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + break; + case SP_ASPECT_XMID_YMAX: + x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); + y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + break; + case SP_ASPECT_XMAX_YMAX: + x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); + y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + break; + default: + x = 0.0; + y = 0.0; + break; + } + } + /* Compose additional transformation from scale and position */ + Geom::Matrix q; + q[0] = width / (symbol->viewBox.x1 - symbol->viewBox.x0); + q[1] = 0.0; + q[2] = 0.0; + q[3] = height / (symbol->viewBox.y1 - symbol->viewBox.y0); + q[4] = -symbol->viewBox.x0 * q[0] + x; + q[5] = -symbol->viewBox.y0 * q[3] + y; + /* Append viewbox transformation */ + symbol->c2p = q * symbol->c2p; + } + + rctx.i2doc = symbol->c2p * (Geom::Matrix)rctx.i2doc; + + /* If viewBox is set initialize child viewport */ + /* Otherwise has set it up already */ + if (symbol->viewBox_set) { + rctx.vp.x0 = symbol->viewBox.x0; + rctx.vp.y0 = symbol->viewBox.y0; + rctx.vp.x1 = symbol->viewBox.x1; + rctx.vp.y1 = symbol->viewBox.y1; + rctx.i2vp = NR::identity(); + } + + /* And invoke parent method */ + if (((SPObjectClass *) (parent_class))->update) + ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); + + /* As last step set additional transform of arena group */ + for (v = item->display; v != NULL; v = v->next) { + nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), symbol->c2p); + } + } else { + /* No-op */ + if (((SPObjectClass *) (parent_class))->update) + ((SPObjectClass *) (parent_class))->update (object, ctx, flags); + } } static void sp_symbol_modified (SPObject *object, guint flags) { - SPSymbol *symbol; + SPSymbol *symbol; - symbol = SP_SYMBOL (object); + symbol = SP_SYMBOL (object); - if (((SPObjectClass *) (parent_class))->modified) - (* ((SPObjectClass *) (parent_class))->modified) (object, flags); + if (((SPObjectClass *) (parent_class))->modified) + (* ((SPObjectClass *) (parent_class))->modified) (object, flags); } static Inkscape::XML::Node * sp_symbol_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPSymbol *symbol; + SPSymbol *symbol; - symbol = SP_SYMBOL (object); + symbol = SP_SYMBOL (object); - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:symbol"); - } + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { + repr = xml_doc->createElement("svg:symbol"); + } - repr->setAttribute("viewBox", object->repr->attribute("viewBox")); - repr->setAttribute("preserveAspectRatio", object->repr->attribute("preserveAspectRatio")); + repr->setAttribute("viewBox", object->repr->attribute("viewBox")); + repr->setAttribute("preserveAspectRatio", object->repr->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (parent_class))->write) + ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); - return repr; + return repr; } static NRArenaItem * sp_symbol_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) { - SPSymbol *symbol; - NRArenaItem *ai; - - symbol = SP_SYMBOL (item); - - if (SP_OBJECT_IS_CLONED (symbol)) { - /* Cloned is actually renderable */ - if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show (item, arena, key, flags); - if (ai) { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), &symbol->c2p); - } - } else { - ai = NULL; - } - } else { - ai = NULL; - } - - return ai; + SPSymbol *symbol; + NRArenaItem *ai; + + symbol = SP_SYMBOL (item); + + if (SP_OBJECT_IS_CLONED (symbol)) { + /* Cloned is actually renderable */ + if (((SPItemClass *) (parent_class))->show) { + ai = ((SPItemClass *) (parent_class))->show (item, arena, key, flags); + if (ai) { + nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), symbol->c2p); + } + } else { + ai = NULL; + } + } else { + ai = NULL; + } + + return ai; } static void sp_symbol_hide (SPItem *item, unsigned int key) { - SPSymbol *symbol; + SPSymbol *symbol; - symbol = SP_SYMBOL (item); + symbol = SP_SYMBOL (item); - if (SP_OBJECT_IS_CLONED (symbol)) { - /* Cloned is actually renderable */ - if (((SPItemClass *) (parent_class))->hide) - ((SPItemClass *) (parent_class))->hide (item, key); - } + if (SP_OBJECT_IS_CLONED (symbol)) { + /* Cloned is actually renderable */ + if (((SPItemClass *) (parent_class))->hide) + ((SPItemClass *) (parent_class))->hide (item, key); + } } static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags) { - SPSymbol const *symbol = SP_SYMBOL(item); + SPSymbol const *symbol = SP_SYMBOL(item); - if (SP_OBJECT_IS_CLONED (symbol)) { - /* Cloned is actually renderable */ + if (SP_OBJECT_IS_CLONED (symbol)) { + /* Cloned is actually renderable */ - if (((SPItemClass *) (parent_class))->bbox) { - NR::Matrix const a( symbol->c2p * transform ); - ((SPItemClass *) (parent_class))->bbox(item, bbox, a, flags); - } - } + if (((SPItemClass *) (parent_class))->bbox) { + Geom::Matrix const a( symbol->c2p * (Geom::Matrix)transform ); + ((SPItemClass *) (parent_class))->bbox(item, bbox, a, flags); + } + } } static void sp_symbol_print (SPItem *item, SPPrintContext *ctx) { - SPSymbol *symbol = SP_SYMBOL(item); - if (SP_OBJECT_IS_CLONED (symbol)) { - /* Cloned is actually renderable */ + SPSymbol *symbol = SP_SYMBOL(item); + if (SP_OBJECT_IS_CLONED (symbol)) { + /* Cloned is actually renderable */ - sp_print_bind(ctx, &symbol->c2p, 1.0); + sp_print_bind(ctx, &symbol->c2p, 1.0); - if (((SPItemClass *) (parent_class))->print) { - ((SPItemClass *) (parent_class))->print (item, ctx); - } + if (((SPItemClass *) (parent_class))->print) { + ((SPItemClass *) (parent_class))->print (item, ctx); + } - sp_print_release (ctx); - } + sp_print_release (ctx); + } } diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 672710fd0..61951cf64 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -25,6 +25,7 @@ class SPSymbol; class SPSymbolClass; #include +#include <2geom/matrix.h> #include #include "svg/svg-length.h" #include "enums.h" @@ -41,7 +42,7 @@ struct SPSymbol : public SPGroup { unsigned int aspect_clip : 1; /* Child to parent additional transform */ - NR::Matrix c2p; + Geom::Matrix c2p; }; struct SPSymbolClass {