comparison OrthancStone/Sources/Scene2D/InfoPanelSceneLayer.cpp @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Scene2D/InfoPanelSceneLayer.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 "InfoPanelSceneLayer.h"
23
24 #include <Images/Image.h>
25 #include <OrthancException.h>
26
27 namespace OrthancStone
28 {
29 InfoPanelSceneLayer::InfoPanelSceneLayer(const Orthanc::ImageAccessor& texture,
30 BitmapAnchor anchor,
31 bool isLinearInterpolation,
32 bool applySceneRotation) :
33 texture_(Orthanc::Image::Clone(texture)),
34 anchor_(anchor),
35 isLinearInterpolation_(isLinearInterpolation),
36 applySceneRotation_(applySceneRotation)
37 {
38 if (texture_->GetFormat() != Orthanc::PixelFormat_RGBA32 &&
39 texture_->GetFormat() != Orthanc::PixelFormat_RGB24)
40 {
41 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
42 }
43 }
44
45
46 void InfoPanelSceneLayer::ComputeAnchorLocation(int& x,
47 int& y,
48 BitmapAnchor anchor,
49 unsigned int textureWidth,
50 unsigned int textureHeight,
51 unsigned int canvasWidth,
52 unsigned int canvasHeight)
53 {
54 int tw = static_cast<int>(textureWidth);
55 int th = static_cast<int>(textureHeight);
56 int cw = static_cast<int>(canvasWidth);
57 int ch = static_cast<int>(canvasHeight);
58
59 switch (anchor)
60 {
61 case BitmapAnchor_TopLeft:
62 case BitmapAnchor_CenterLeft:
63 case BitmapAnchor_BottomLeft:
64 x = 0;
65 break;
66
67 case BitmapAnchor_TopCenter:
68 case BitmapAnchor_Center:
69 case BitmapAnchor_BottomCenter:
70 x = (cw - tw) / 2;
71 break;
72
73 case BitmapAnchor_TopRight:
74 case BitmapAnchor_CenterRight:
75 case BitmapAnchor_BottomRight:
76 x = cw - tw;
77 break;
78
79 default:
80 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
81 }
82
83 switch (anchor)
84 {
85 case BitmapAnchor_TopLeft:
86 case BitmapAnchor_TopCenter:
87 case BitmapAnchor_TopRight:
88 y = 0;
89 break;
90
91 case BitmapAnchor_CenterLeft:
92 case BitmapAnchor_Center:
93 case BitmapAnchor_CenterRight:
94 y = (ch - th) / 2;
95 break;
96
97 case BitmapAnchor_BottomLeft:
98 case BitmapAnchor_BottomCenter:
99 case BitmapAnchor_BottomRight:
100 y = ch - th;
101 break;
102
103 default:
104 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
105 }
106 }
107 }