comparison OrthancStone/Sources/Toolbox/OsiriX/Annotation.cpp @ 1584:bd180f97c734

parsing osirix annotations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 21 Oct 2020 17:33:17 +0200
parents
children 4fb8fdf03314
comparison
equal deleted inserted replaced
1583:c8644706e78b 1584:bd180f97c734
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-2020 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 "Annotation.h"
23
24 #include "AngleAnnotation.h"
25 #include "IntegerValue.h"
26 #include "LineAnnotation.h"
27 #include "StringValue.h"
28 #include "TextAnnotation.h"
29
30 #include <Logging.h>
31
32 namespace OrthancStone
33 {
34 namespace OsiriX
35 {
36 void Annotation::SetupCommon(const DictionaryValue& dict)
37 {
38 const IValue* value = dict.LookupValue("Name");
39 if (value == NULL)
40 {
41 name_.clear();
42 }
43 else
44 {
45 name_ = dynamic_cast<const StringValue&>(*value).GetValue();
46 }
47
48 value = dict.LookupValue("StudyInstanceUID");
49 if (value == NULL)
50 {
51 studyInstanceUid_.clear();
52 }
53 else
54 {
55 studyInstanceUid_ = dynamic_cast<const StringValue&>(*value).GetValue();
56 }
57
58 value = dict.LookupValue("SeriesInstanceUID");
59 if (value == NULL)
60 {
61 seriesInstanceUid_.clear();
62 }
63 else
64 {
65 seriesInstanceUid_ = dynamic_cast<const StringValue&>(*value).GetValue();
66 }
67
68 value = dict.LookupValue("SOPInstanceUID");
69 if (value == NULL)
70 {
71 sopInstanceUid_.clear();
72 }
73 else
74 {
75 sopInstanceUid_ = dynamic_cast<const StringValue&>(*value).GetValue();
76 }
77 }
78
79
80 Annotation* Annotation::Create(const DictionaryValue& dict)
81 {
82 const IntegerValue& type = dynamic_cast<const IntegerValue&>(dict.GetValue("Type"));
83
84 switch (type.GetValue())
85 {
86 case 5:
87 return new LineAnnotation(dict, false);
88
89 case 12:
90 return new AngleAnnotation(dict);
91
92 case 13:
93 return new TextAnnotation(dict);
94
95 case 14:
96 return new LineAnnotation(dict, true);
97
98 default:
99 LOG(WARNING) << "Unsupported OsiriX annotation type: " << type.GetValue();
100 return NULL;
101 }
102 }
103 }
104 }