index eeda6f1879bf784d1f9f2c58558cfa1bdfae296d..44b64c5f8f999fdb3da78ec39b81ce0846d696d0 100644 (file)
-#define __SP_LATEX_C__
-
/*
* LaTeX Printing
*
* Author:
* Michael Forbes <miforbes@mbhs.edu>
+ * Abhishek Sharma
*
* Copyright (C) 2004 Authors
*
#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 <2geom/pathvector.h>
#include <2geom/sbasis-to-bezier.h>
#include <2geom/bezier-curve.h>
}
// width and height in pt
- _width = sp_document_width(doc) * PT_PER_PX;
- _height = sp_document_height(doc) * PT_PER_PX;
+ _width = doc->getWidth() * PT_PER_PX;
+ _height = doc->getHeight() * PT_PER_PX;
if (res >= 0) {
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";
+ os << "\\begin{pspicture}(" << doc->getWidth() << "," << doc->getHeight() << ")\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, doc->getHeight()));
return fprintf(_stream, "%s", os.str().c_str());
}
}
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);
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.
if (style->fill.isColor()) {
Inkscape::SVGOStringStream os;
float rgb[3];
+ float fill_opacity;
os.setf(std::ios::fixed);
+ fill_opacity=SP_SCALE24_TO_FLOAT(style->fill_opacity.value);
sp_color_get_rgb_floatv(&style->fill.value.color, rgb);
os << "{\n\\newrgbcolor{curcolor}{" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "}\n";
+ os << "\\pscustom[linestyle=none,fillstyle=solid,fillcolor=curcolor";
+ if (fill_opacity!=1.0) {
+ os << ",opacity="<<fill_opacity;
+ }
- os << "\\pscustom[linestyle=none,fillstyle=solid,fillcolor=curcolor]\n{\n";
+ os << "]\n{\n";
print_pathvector(os, pathv, transform);
}
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,14 +235,20 @@ 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);
+ float stroke_opacity;
+ Geom::Matrix tr_stack = m_tr_stack.top();
+ double const scale = tr_stack.descrim();
os.setf(std::ios::fixed);
+ stroke_opacity=SP_SCALE24_TO_FLOAT(style->stroke_opacity.value);
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*scale<< ",linecolor=curcolor";
+
+ if (stroke_opacity!=1.0) {
+ os<<",strokeopacity="<<stroke_opacity;
+ }
if (style->stroke_dasharray_set &&
style->stroke_dash.n_dash &&
@@ -274,13 +277,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";
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :