summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-1.2.1/src/EPSToSVG.h
blob: 92edb5884e089c80de47966c5df12c9ef9ecd263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*************************************************************************
** EPSToSVG.h                                                           **
**                                                                      **
** This file is part of dvisvgm -- the DVI to SVG converter             **
** Copyright (C) 2005-2013 Martin Gieseking <martin.gieseking@uos.de>   **
**                                                                      **
** This program is free software; you can redistribute it and/or        **
** modify it under the terms of the GNU General Public License as       **
** published by the Free Software Foundation; either version 3 of       **
** the License, or (at your option) any later version.                  **
**                                                                      **
** This program is distributed in the hope that it will be useful, but  **
** WITHOUT ANY WARRANTY; without even the implied warranty of           **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         **
** GNU General Public License for more details.                         **
**                                                                      **
** You should have received a copy of the GNU General Public License    **
** along with this program; if not, see <http://www.gnu.org/licenses/>. **
*************************************************************************/

#ifndef EPSTOSVG_H
#define EPSTOSVG_H

#include <string>
#include "SpecialActions.h"
#include "SVGTree.h"

struct SVGOutputBase;

class EPSToSVG : protected SpecialActions
{
	public:
		EPSToSVG (const std::string &fname, SVGOutputBase &out) : _fname(fname), _out(out), _x(0), _y(0) {}
		void convert ();
		void setTransformation (const Matrix &m);
		void setPageSize (const std::string &name);

	protected:
		// implement abstract base class SpecialActions
		double getX () const                    {return _x;}
		double getY () const                    {return _y;}
		void setX (double x)                    {_x = x; _svg.setX(x);}
		void setY (double y)                    {_y = y; _svg.setY(y);}
		void finishLine ()                      {}
		void setColor (const Color &color)      {_svg.setColor(color);}
		Color getColor () const                 {return _svg.getColor();}
		void setMatrix (const Matrix &m)        {_svg.setMatrix(m);}
		const Matrix& getMatrix () const        {return _svg.getMatrix();}
		void setBgColor (const Color &color)    {}
		void appendToPage (XMLNode *node)       {_svg.appendToPage(node);}
		void appendToDefs (XMLNode *node)       {_svg.appendToDefs(node);}
		void embed (const BoundingBox &bbox)    {_bbox.embed(bbox);}
		void embed (const DPair &p, double r=0) {if (r==0) _bbox.embed(p); else _bbox.embed(p, r);}
		BoundingBox& bbox ()                    {return _bbox;}
		BoundingBox& bbox (const std::string &name, bool reset=false) {return _bbox;}

	private:
		std::string _fname;   ///< name of EPS file
		SVGTree _svg;
		SVGOutputBase &_out;
		double _x, _y;
		BoundingBox _bbox;
};

#endif