index a2d0d87f7a02fef8d4066624b733d19b3fe6d1f9..116cccb3be45a30d1e9dee8fd2fa551499074aae 100644 (file)
#include <signal.h>
#include <errno.h>
+
+#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 <libnr/nr-matrix-fns.h>
+
+
#include "libnr/n-art-bpath.h"
#include "sp-item.h"
_width = sp_document_width(doc) * PT_PER_PX;
_height = sp_document_height(doc) * PT_PER_PX;
- NRRect d;
- bool pageLandscape;
- // printf("Page Bounding Box: %s\n", pageBoundingBox ? "TRUE" : "FALSE");
-/* if (pageBoundingBox) {
- d.x0 = d.y0 = 0;
- d.x1 = ceil(_width);
- d.y1 = ceil(_height);
- } else */{ // no bounding boxes for now
- SPItem* doc_item = SP_ITEM(sp_document_root(doc));
- sp_item_invoke_bbox(doc_item, &d, sp_item_i2r_affine(doc_item), TRUE);
- // 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;
- }
-
-
if (res >= 0) {
os << "%%Creator: " << PACKAGE_STRING << "\n";
os << "%%Please note this file requires PSTricks extensions\n";
- // 2004 Dec 10, BFC:
- // The point of the following code is (1) to do the thing that's expected by users
- // who have done File>New>A4_landscape or ...letter_landscape (i.e., rotate
- // the output), while (2) not messing up users who simply want their output wider
- // than it is tall (e.g., small figures for inclusion in LaTeX).
- // The original patch by WQ only had the w>h condition.
- {
- double w = (d.x1 - d.x0); // width and height of bounding box, in pt
- double h = (d.y1 - d.y0);
- pageLandscape = (
- (w > 0. && h > 0.) // empty documents fail this sanity check, have w<0, h<0
- && (w > h) // implies, but does not prove, the user wanted landscape
- && (w > 600) // approximate maximum printable width of an A4
- )
- ? true : false;
- }
-
- if (pageLandscape) {
- os << "\\rotate{90}\n";
- }
-
os << "\\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}\n";
// from now on we can output px, but they will be treated as pt
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());
}
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)
{
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
Inkscape::SVGOStringStream os;
float rgb[3];
@@ -239,16 +233,17 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, const NRBPath *bpath, const
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
- if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ if (style->stroke.isColor()) {
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 &&
@@ -280,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];