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 #include "Glyph.h"
|
|
23
|
|
24 #include <Core/OrthancException.h>
|
|
25
|
|
26
|
|
27 namespace OrthancStone
|
|
28 {
|
|
29 Glyph::Glyph(const Glyph& other) :
|
|
30 width_(other.width_),
|
|
31 height_(other.height_),
|
|
32 offsetLeft_(other.offsetLeft_),
|
|
33 offsetTop_(other.offsetTop_),
|
|
34 advanceX_(other.advanceX_),
|
|
35 lineHeight_(other.lineHeight_)
|
|
36 {
|
|
37 }
|
|
38
|
|
39
|
|
40 Glyph::Glyph(unsigned int width,
|
|
41 unsigned int height,
|
|
42 int offsetLeft,
|
|
43 int offsetTop,
|
|
44 int advanceX,
|
|
45 unsigned int lineHeight) :
|
|
46 width_(width),
|
|
47 height_(height),
|
|
48 offsetLeft_(offsetLeft),
|
|
49 offsetTop_(offsetTop),
|
|
50 advanceX_(advanceX),
|
|
51 lineHeight_(lineHeight)
|
|
52 {
|
|
53 }
|
|
54
|
|
55
|
|
56 void Glyph::SetPayload(Orthanc::IDynamicObject* payload) // Takes ownership
|
|
57 {
|
|
58 if (payload == NULL)
|
|
59 {
|
|
60 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
|
|
61 }
|
|
62 else
|
|
63 {
|
|
64 payload_.reset(payload);
|
|
65 }
|
|
66 }
|
|
67
|
|
68
|
|
69 const Orthanc::IDynamicObject& Glyph::GetPayload() const
|
|
70 {
|
|
71 if (payload_.get() == NULL)
|
|
72 {
|
|
73 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
|
|
74 }
|
|
75 else
|
|
76 {
|
|
77 return *payload_;
|
|
78 }
|
|
79 }
|
|
80
|
|
81
|
|
82 Orthanc::IDynamicObject* Glyph::ReleasePayload()
|
|
83 {
|
|
84 if (payload_.get() == NULL)
|
|
85 {
|
|
86 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
|
|
87 }
|
|
88 else
|
|
89 {
|
|
90 return payload_.release();
|
|
91 }
|
|
92 }
|
|
93 }
|