From: ishmal Date: Sat, 19 May 2007 10:14:37 +0000 (+0000) Subject: Applied Yossi's patch 1721693 for bugs 1718405, 1718934, and 1720822 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=22c86d6dc2d3dc9508a464e6ccb0e75430b88c86;p=inkscape.git Applied Yossi's patch 1721693 for bugs 1718405, 1718934, and 1720822 --- diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index f86159449..990c094a4 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -19,6 +19,16 @@ #include #include + +#include "libnr/nr-matrix.h" +#include "libnr/nr-matrix-ops.h" +#include "libnr/nr-matrix-scale-ops.h" +#include "libnr/nr-matrix-translate-ops.h" +#include "libnr/nr-scale-translate-ops.h" +#include "libnr/nr-translate-scale-ops.h" +#include + + #include "libnr/n-art-bpath.h" #include "sp-item.h" @@ -138,6 +148,8 @@ 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))); + return fprintf(_stream, "%s", os.str().c_str()); } @@ -158,6 +170,27 @@ PrintLatex::finish (Inkscape::Extension::Print *mod) return 0; } +unsigned int +PrintLatex::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, float opacity) +{ + NR::Matrix tr = *transform; + + if(m_tr_stack.size()){ + NR::Matrix tr_top = m_tr_stack.top(); + m_tr_stack.push(tr * tr_top); + }else + m_tr_stack.push(tr); + + return 1; +} + +unsigned int +PrintLatex::release(Inkscape::Extension::Print *mod) +{ + m_tr_stack.pop(); + return 1; +} + unsigned int PrintLatex::comment (Inkscape::Extension::Print * module, const char * comment) { @@ -203,13 +236,14 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, const NRBPath *bpath, const if (style->stroke.type == SP_PAINT_TYPE_COLOR) { Inkscape::SVGOStringStream os; float rgb[3]; - + NR::Matrix tr_stack = m_tr_stack.top(); + double const scale = expansion(tr_stack); os.setf(std::ios::fixed); sp_color_get_rgb_floatv(&style->stroke.value.color, rgb); os << "{\n\\newrgbcolor{curcolor}{" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "}\n"; - os << "\\pscustom[linewidth=" << style->stroke_width.computed<< ",linecolor=curcolor"; + os << "\\pscustom[linewidth=" << style->stroke_width.computed*scale<< ",linecolor=curcolor"; if (style->stroke_dasharray_set && style->stroke_dash.n_dash && @@ -241,16 +275,22 @@ PrintLatex::print_bpath(SVGOStringStream &os, const NArtBpath *bp, const NRMatri { unsigned int closed; NR::Matrix tf=*transform; - + NR::Matrix tf_stack=m_tr_stack.top(); os << "\\newpath\n"; closed = FALSE; while (bp->code != NR_END) { using NR::X; using NR::Y; - NR::Point const p1(bp->c(1) * tf); - NR::Point const p2(bp->c(2) * tf); - NR::Point const p3(bp->c(3) * tf); + +// NR::Point const p1(bp->c(1) * tf); +// NR::Point const p2(bp->c(2) * tf); +// NR::Point const p3(bp->c(3) * tf); + + NR::Point const p1(bp->c(1) * tf_stack); + NR::Point const p2(bp->c(2) * tf_stack); + NR::Point const p3(bp->c(3) * tf_stack); + double const x1 = p1[X], y1 = p1[Y]; double const x2 = p2[X], y2 = p2[Y]; double const x3 = p3[X], y3 = p3[Y]; diff --git a/src/extension/internal/latex-pstricks.h b/src/extension/internal/latex-pstricks.h index 9238fe606..0e1500630 100644 --- a/src/extension/internal/latex-pstricks.h +++ b/src/extension/internal/latex-pstricks.h @@ -19,6 +19,8 @@ #include "svg/stringstream.h" +#include + namespace Inkscape { namespace Extension { namespace Internal { @@ -28,8 +30,10 @@ class PrintLatex : public Inkscape::Extension::Implementation::Implementation { float _width; float _height; FILE * _stream; + + std::stack m_tr_stack; - void print_bpath (SVGOStringStream &os, const NArtBpath *bp, const NRMatrix *transform); + void print_bpath (SVGOStringStream &os, const NArtBpath *bp, const NRMatrix *transform); public: PrintLatex (void); @@ -42,7 +46,10 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *ctm, const SPStyle *style, + virtual unsigned int bind(Inkscape::Extension::Print *module, NRMatrix const *transform, float opacity); + virtual unsigned int release(Inkscape::Extension::Print *module); + + virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);