summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 48f5db4)
raw | patch | inline | side by side (parent: 48f5db4)
author | Johan Engelen <goejendaagh@zonnet.nl> | |
Sun, 21 Feb 2010 11:39:17 +0000 (12:39 +0100) | ||
committer | Johan Engelen <goejendaagh@zonnet.nl> | |
Sun, 21 Feb 2010 11:39:17 +0000 (12:39 +0100) |
src/extension/internal/pdflatex-renderer.cpp | patch | blob | history | |
src/extension/internal/pdflatex-renderer.h | patch | blob | history |
diff --git a/src/extension/internal/pdflatex-renderer.cpp b/src/extension/internal/pdflatex-renderer.cpp
index 0d2ffcc94e2a02956b0d3d7253defbcbfbe08894..d21457a8945dbcca38c5e7433c0908fdc7001eb2 100644 (file)
PDFLaTeXRenderer::PDFLaTeXRenderer(void)
: _stream(NULL),
_filename(NULL),
- _m(Geom::identity()),
_width(0),
_height(0)
-{}
+{
+ push_transform(Geom::identity());
+}
PDFLaTeXRenderer::~PDFLaTeXRenderer(void)
{
{
SPText *textobj = SP_TEXT (item);
+ push_transform(sp_item_i2doc_affine(item));
+
gchar *str = sp_te_get_string_multiline(item);
- Geom::Point pos = SP_TEXT(item)->attributes.firstXY();
+ Geom::Point pos = textobj->attributes.firstXY() * transform();
gchar *alignment = "lb";
+ pop_transform();
+
// write to LaTeX
Inkscape::SVGOStringStream os;
// ctx->pushState();
// setStateForItem(ctx, item);
-// Geom::Matrix tempmat (root->c2p);
-// ctx->transform(&tempmat);
+ Geom::Matrix tempmat (root->c2p);
+ push_transform(tempmat);
sp_group_render(item);
-// ctx->popState();
+ pop_transform();
}
void
@@ -470,23 +475,22 @@ PDFLaTeXRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *b
}
// convert from px to pt
- d.x0 *= PT_PER_PX;
- d.x1 *= PT_PER_PX;
- d.y0 *= PT_PER_PX;
- d.y1 *= PT_PER_PX;
-
- _width = d.x1-d.x0;
- _height = d.y1-d.y0;
+ push_transform( Geom::Scale(PT_PER_PX, PT_PER_PX) );
if (!pageBoundingBox)
{
double high = sp_document_height(doc);
- high *= PT_PER_PX;
- transform( Geom::Translate( -d.x0 * PX_PER_PT,
- (d.y1 - high) * PX_PER_PT ) );
+ push_transform( Geom::Translate( -d.x0,
+ -d.y0 ) );
}
+ // flip y-axis
+ push_transform( Geom::Scale(1,-1) * Geom::Translate(0, sp_document_height(doc)) );
+
+ _width = (d.x1-d.x0) * PT_PER_PX;
+ _height = (d.y1-d.y0) * PT_PER_PX;
+
// write the info to LaTeX
Inkscape::SVGOStringStream os;
@@ -500,12 +504,28 @@ PDFLaTeXRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *b
return true;
}
+Geom::Matrix const &
+PDFLaTeXRenderer::transform()
+{
+ return _transform_stack.top();
+}
+
void
-PDFLaTeXRenderer::transform(Geom::Matrix const &transform)
+PDFLaTeXRenderer::push_transform(Geom::Matrix const &tr)
{
- _m *= transform;
+ if(_transform_stack.size()){
+ Geom::Matrix tr_top = _transform_stack.top();
+ _transform_stack.push(tr * tr_top);
+ } else {
+ _transform_stack.push(tr);
+ }
}
+void
+PDFLaTeXRenderer::pop_transform()
+{
+ _transform_stack.pop();
+}
/*
#include "macros.h" // SP_PRINT_*
diff --git a/src/extension/internal/pdflatex-renderer.h b/src/extension/internal/pdflatex-renderer.h
index 856631f95dc9da8a27d32ceec35c9cbab1718b4d..93c06b1149a75083876bb3740ffd57be0690b0f3 100644 (file)
#include <cairo.h>
#include <2geom/matrix.h>
+#include <stack>
class SPClipPath;
class SPMask;
FILE * _stream;
gchar * _filename;
- void transform(Geom::Matrix const &transform);
- Geom::Matrix _m; // the transform for current item
+ void push_transform(Geom::Matrix const &transform);
+ Geom::Matrix const & transform();
+ void pop_transform();
+ std::stack<Geom::Matrix> _transform_stack;
double _width;
double _height;