Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/StoneEnumerations.cpp @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/StoneEnumerations.cpp@30deba7bc8e2 |
children | 4fb8fdf03314 |
comparison
equal
deleted
inserted
replaced
1511:9dfeee74c1e6 | 1512:244ad1e4e76a |
---|---|
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 "StoneEnumerations.h" | |
23 | |
24 #include <Logging.h> | |
25 #include <OrthancException.h> | |
26 #include <Toolbox.h> | |
27 | |
28 namespace OrthancStone | |
29 { | |
30 SopClassUid StringToSopClassUid(const std::string& source) | |
31 { | |
32 std::string s = Orthanc::Toolbox::StripSpaces(source); | |
33 | |
34 if (s == "1.2.840.10008.5.1.4.1.1.481.2") | |
35 { | |
36 return SopClassUid_RTDose; | |
37 } | |
38 else | |
39 { | |
40 //LOG(INFO) << "Other SOP class UID: " << source; | |
41 return SopClassUid_Other; | |
42 } | |
43 } | |
44 | |
45 | |
46 void ComputeWindowing(float& targetCenter, | |
47 float& targetWidth, | |
48 ImageWindowing windowing, | |
49 float customCenter, | |
50 float customWidth) | |
51 { | |
52 switch (windowing) | |
53 { | |
54 case ImageWindowing_Custom: | |
55 targetCenter = customCenter; | |
56 targetWidth = customWidth; | |
57 break; | |
58 | |
59 case ImageWindowing_Bone: | |
60 targetCenter = 300; | |
61 targetWidth = 2000; | |
62 break; | |
63 | |
64 case ImageWindowing_Lung: | |
65 targetCenter = -600; | |
66 targetWidth = 1600; | |
67 break; | |
68 | |
69 default: | |
70 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
71 } | |
72 } | |
73 | |
74 | |
75 void ComputeAnchorTranslation(double& deltaX, | |
76 double& deltaY, | |
77 BitmapAnchor anchor, | |
78 unsigned int bitmapWidth, | |
79 unsigned int bitmapHeight, | |
80 unsigned int border) | |
81 { | |
82 double dw = static_cast<double>(bitmapWidth); | |
83 double dh = static_cast<double>(bitmapHeight); | |
84 | |
85 switch (anchor) | |
86 { | |
87 case BitmapAnchor_TopLeft: | |
88 deltaX = 0; | |
89 deltaY = 0; | |
90 break; | |
91 | |
92 case BitmapAnchor_TopCenter: | |
93 deltaX = -dw / 2.0; | |
94 deltaY = 0; | |
95 break; | |
96 | |
97 case BitmapAnchor_TopRight: | |
98 deltaX = -dw; | |
99 deltaY = 0; | |
100 break; | |
101 | |
102 case BitmapAnchor_CenterLeft: | |
103 deltaX = 0; | |
104 deltaY = -dh / 2.0; | |
105 break; | |
106 | |
107 case BitmapAnchor_Center: | |
108 deltaX = -dw / 2.0; | |
109 deltaY = -dh / 2.0; | |
110 break; | |
111 | |
112 case BitmapAnchor_CenterRight: | |
113 deltaX = -dw; | |
114 deltaY = -dh / 2.0; | |
115 break; | |
116 | |
117 case BitmapAnchor_BottomLeft: | |
118 deltaX = 0; | |
119 deltaY = -dh; | |
120 break; | |
121 | |
122 case BitmapAnchor_BottomCenter: | |
123 deltaX = -dw / 2.0; | |
124 deltaY = -dh; | |
125 break; | |
126 | |
127 case BitmapAnchor_BottomRight: | |
128 deltaX = -dw; | |
129 deltaY = -dh; | |
130 break; | |
131 | |
132 default: | |
133 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
134 } | |
135 | |
136 if (border != 0) | |
137 { | |
138 double b = static_cast<double>(border); | |
139 | |
140 switch (anchor) | |
141 { | |
142 case BitmapAnchor_TopLeft: | |
143 case BitmapAnchor_TopCenter: | |
144 case BitmapAnchor_TopRight: | |
145 deltaY += b; | |
146 break; | |
147 | |
148 case BitmapAnchor_BottomLeft: | |
149 case BitmapAnchor_BottomCenter: | |
150 case BitmapAnchor_BottomRight: | |
151 deltaY -= b; | |
152 break; | |
153 | |
154 default: | |
155 break; | |
156 } | |
157 | |
158 switch (anchor) | |
159 { | |
160 case BitmapAnchor_TopLeft: | |
161 case BitmapAnchor_CenterLeft: | |
162 case BitmapAnchor_BottomLeft: | |
163 deltaX += b; | |
164 break; | |
165 | |
166 case BitmapAnchor_CenterRight: | |
167 case BitmapAnchor_TopRight: | |
168 case BitmapAnchor_BottomRight: | |
169 deltaX -= b; | |
170 break; | |
171 | |
172 default: | |
173 break; | |
174 } | |
175 } | |
176 } | |
177 } |