-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglsvg.hpp
82 lines (62 loc) · 1.86 KB
/
glsvg.hpp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef GLSVG
#define GLSVG
#include <deque>
using std::deque;
#include <istream>
using std::istream;
#include <stdexcept>
using std::runtime_error;
#include <boost/filesystem.hpp>
using boost::filesystem::path;
#include <boost/filesystem/fstream.hpp>
using boost::filesystem::ifstream;
#include "pugixml/pugixml.hpp"
using pugi::xml_node;
namespace glsvg
{
/// Base class for all svg document elements
class Elem
{
public:
Elem(const weak_ptr<Elem> &parent);
/// Draw this element to the current framebuffer
virtual void draw();
/// Compile this element to a display list
virtual void compile(const int listid);
/// Dispatch to the correct element constructor, based on the node
static unique_ptr<Elem> construct(const xml_node &rootnode);
protected:
/// The children of the given element
deque<shared_ptr<Elem>> mChildren;
/// The parent of the given element
weak_ptr<Elem> mParent;
};
/// Corresponds to an <svg> element
class Svg : public Elem
{
public:
/// Initialize this svg document from the given istream
Svg(istream &inputstream);
/// Initialize this svg document from the specified file
Svg(const string &pathname);
/// Initialize this svg document from the specified file
Svg(const path &pathname);
/// Initialize this svg document from the specified xml node
Svg(const xml_node &rootnode, const weak_ptr<Elem> &parent);
/// Draw this svg document to the current framebuffer
virtual void draw() = 0;
};
/// Corresponds to a <rect> element
class Rect : public Elem
{
public:
/// Initialize this rect from the given xml node
Rect(const xml_node &rootnode, const weak_ptr<Elem> &parent);
/// Draw this rect to the current framebuffer
virtual void draw();
};
class SvgRuntimeError : public runtime_error
{
SvgRuntimeError(string what);
};
#endif