576
|
1 /**
|
|
2 * Stone of Orthanc
|
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
4 * Department, University Hospital of Liege, Belgium
|
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
|
|
6 *
|
|
7 * This program is free software: you can redistribute it and/or
|
|
8 * modify it under the terms of the GNU Affero General Public License
|
|
9 * as published by the Free Software Foundation, either version 3 of
|
|
10 * the License, or (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful, but
|
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
15 * Affero General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU Affero General Public License
|
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19 **/
|
|
20
|
|
21
|
|
22 #pragma once
|
|
23
|
|
24 #include "FontRenderer.h"
|
|
25
|
|
26 #include <Core/Enumerations.h>
|
|
27
|
|
28 #include <map>
|
|
29
|
|
30 namespace OrthancStone
|
|
31 {
|
|
32 class GlyphAlphabet : public boost::noncopyable
|
|
33 {
|
|
34 public:
|
|
35 class ITextVisitor : public boost::noncopyable
|
|
36 {
|
|
37 public:
|
|
38 virtual ~ITextVisitor()
|
|
39 {
|
|
40 }
|
|
41
|
|
42 virtual void Visit(uint32_t unicode,
|
|
43 int x,
|
|
44 int y,
|
|
45 unsigned int width,
|
|
46 unsigned int height,
|
|
47 const Orthanc::IDynamicObject* payload /* can be NULL */) = 0;
|
|
48 };
|
|
49
|
|
50
|
|
51 class IGlyphVisitor : public boost::noncopyable
|
|
52 {
|
|
53 public:
|
|
54 virtual ~IGlyphVisitor()
|
|
55 {
|
|
56 }
|
|
57
|
|
58 virtual void Visit(uint32_t unicode,
|
|
59 const Glyph& glyph) = 0;
|
|
60 };
|
|
61
|
|
62
|
|
63 private:
|
|
64 typedef std::map<uint32_t, Glyph*> Content;
|
|
65
|
|
66 Content content_;
|
|
67 unsigned int lineHeight_;
|
|
68
|
|
69 public:
|
|
70 GlyphAlphabet() :
|
|
71 lineHeight_(0)
|
|
72 {
|
|
73 }
|
|
74
|
|
75 ~GlyphAlphabet()
|
|
76 {
|
|
77 Clear();
|
|
78 }
|
|
79
|
|
80 void Clear();
|
|
81
|
|
82 void Register(uint32_t unicode,
|
|
83 const Glyph& glyph,
|
|
84 Orthanc::IDynamicObject* payload);
|
|
85
|
|
86 void Register(FontRenderer& renderer,
|
|
87 uint32_t unicode);
|
|
88
|
|
89 #if ORTHANC_ENABLE_LOCALE == 1
|
|
90 static bool GetUnicodeFromCodepage(uint32_t& unicode,
|
|
91 unsigned int index,
|
|
92 Orthanc::Encoding encoding);
|
|
93 #endif
|
|
94
|
|
95 size_t GetSize() const
|
|
96 {
|
|
97 return content_.size();
|
|
98 }
|
|
99
|
|
100 void Apply(IGlyphVisitor& visitor) const;
|
|
101
|
|
102 void Apply(ITextVisitor& visitor,
|
|
103 const std::string& utf8) const;
|
|
104 };
|
|
105 }
|