Merge branch 'master' of git.ucc.asn.au:ipdf/code
[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 namespace IPDF
8 {
9         class Document
10         {
11                 public:
12                         Document(const std::string & filename = "") : m_objects(), m_count(0) {Load(filename);}
13                         virtual ~Document() {}
14                         
15                         void LoadSVG(const std::string & filename, const Rect & bounds = {0,0,1,1});
16
17                         void Load(const std::string & filename = "");
18                         void Save(const std::string & filename);
19                         void DebugDumpObjects();
20
21                         unsigned ObjectCount() const {return m_count;}
22                         inline const Objects & GetObjects() const {return m_objects;}
23
24                         bool operator==(const Document & equ) const;
25                         bool operator!=(const Document & equ) const {return !(this->operator==(equ));}
26
27                         void Add(ObjectType type, const Rect & bounds, unsigned data_index = 0);
28                         unsigned AddBezierData(const Bezier & bezier);
29                         
30                         void AddPathFromString(const std::string & d, const Rect & bounds);
31
32 #ifndef QUADTREE_DISABLED
33                         inline const QuadTree& GetQuadTree() { if (m_quadtree.root_id == QUADTREE_EMPTY) { GenBaseQuadtree(); } return m_quadtree; }
34                         QuadTreeIndex GenQuadChild(QuadTreeIndex parent, QuadTreeNodeChildren type);
35                         QuadTreeIndex GenQuadParent(QuadTreeIndex child, QuadTreeNodeChildren mytype);
36 #endif
37
38                 private:
39                         friend class View;
40                         Objects m_objects;
41 #ifndef QUADTREE_DISABLED
42                         QuadTree m_quadtree;
43                         void GenBaseQuadtree();
44 #endif
45                         unsigned m_count;
46                         
47
48         };
49 }
50
51 #endif //_DOCUMENT_H

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