Deal with groups in SVG parsing
[ipdf/code.git] / src / document.h
1 #ifndef _DOCUMENT_H
2 #define _DOCUMENT_H
3
4 #include "ipdf.h"
5 #include "quadtree.h"
6
7 #include "../contrib/pugixml-1.4/src/pugixml.hpp"
8
9
10 typedef struct stbtt_fontinfo stbtt_fontinfo;
11
12 namespace IPDF
13 {
14         class Document
15         {
16                 public:
17                         Document(const std::string & filename = "") : m_objects(), m_count(0) {Load(filename);}
18                         virtual ~Document() {}
19                         
20                         
21
22                         void Load(const std::string & filename = "");
23                         void Save(const std::string & filename);
24                         void DebugDumpObjects();
25
26                         unsigned ObjectCount() const {return m_count;}
27                         inline const Objects & GetObjects() const {return m_objects;}
28
29                         bool operator==(const Document & equ) const;
30                         bool operator!=(const Document & equ) const {return !(this->operator==(equ));}
31
32                         void Add(ObjectType type, const Rect & bounds, unsigned data_index = 0);
33                         unsigned AddBezierData(const Bezier & bezier);
34                         
35                         
36                         
37                         
38                         /** SVG Related functions **/
39                         
40                         /** Load an SVG text file and add to the document **/
41                         void LoadSVG(const std::string & filename, const Rect & bounds = Rect(0,0,1,1));
42                         
43                         /** Parse an SVG node or SVG-group node, adding children to the document **/
44                         void ParseSVGNode(pugi::xml_node & root, const Rect & bounds, Real & width, Real & height);
45                         /** Parse an SVG path with string **/
46                         void ParseSVGPathData(const std::string & d, const Rect & bounds);
47
48                         void AddFontGlyphAtPoint(stbtt_fontinfo *font, int character, Real scale, Real x, Real y);
49
50 #ifndef QUADTREE_DISABLED
51                         inline const QuadTree& GetQuadTree() { if (m_quadtree.root_id == QUADTREE_EMPTY) { GenBaseQuadtree(); } return m_quadtree; }
52                         QuadTreeIndex GenQuadChild(QuadTreeIndex parent, QuadTreeNodeChildren type);
53                         QuadTreeIndex GenQuadParent(QuadTreeIndex child, QuadTreeNodeChildren mytype);
54 #endif
55
56                 private:
57                         friend class View;
58                         Objects m_objects;
59 #ifndef QUADTREE_DISABLED
60                         QuadTree m_quadtree;
61                         void GenBaseQuadtree();
62 #endif
63                         unsigned m_count;
64                         
65
66         };
67 }
68
69 #endif //_DOCUMENT_H

UCC git Repository :: git.ucc.asn.au